Validator for field in table

Hello,
I have table with editable fields and a factory, which adds an item, when the last item is not empty. When a field has validator, it is impossible to set its value to an invalid one and add a new item: when setting invalid value to the last item, in the moment a new item appears, the wrong value disappear. If there are more items in the table, it is possible to set invalid value, but in the moment of adding new item, all wrong values disappear. Is there a way to implement the feature for desired behavior?
Below I’m attaching the code:

        table.setContainerDataSource(new BeanItemContainer<EnumValueDescriptor>(EnumValueDescriptor.class));
        table.setVisibleColumns(COLUMNS_ORDER);
        table.setEditable(true);
        table.setImmediate(true);
        table.addItem(new EnumValueDescriptor());
        table.setTableFieldFactory(new AddBeanFieldFactory<EnumValueDescriptor>(EnumValueDescriptor.class){
            @Override
            public Field<?> createField(Container container, final Object itemId,
                    Object propertyId, Component uiContext) {
                Field<?> field = super.createField(container, itemId, propertyId, uiContext);
                final SQLValidator<EnumValueFields> validator = new SQLValidator<EnumValueFields>(EnumValueStatements.INSERT,
                        COLUMNS[ArrayUtils.indexOf(COLUMNS_ORDER, propertyId)]
);
                try {
                    validator.setConnection(connection);
                    field.addValidator(validator);
                } catch (SQLException e) {
                    // should not happen, if yes --> no validation against the database
                    log.error(e);
                }
                return field;
            }
        });
package cz.pse.services.component.table;

import com.vaadin.data.Container;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.ui.AbstractField;
import com.vaadin.ui.AbstractTextField;
import com.vaadin.ui.Component;
import com.vaadin.ui.DefaultFieldFactory;
import com.vaadin.ui.Field;
import com.vaadin.ui.Table;
import com.vaadin.ui.TableFieldFactory;

/**
 * {@link TableFieldFactory}, that adds a new bean to the {@link BeanItemContainer}, when edited last
 * row property has not null value.
 *
 * @param <T> bean type in {@link BeanItemContainer}. Bean requires unparameterized constructor.
 */
@SuppressWarnings("serial")
public class AddBeanFieldFactory<T> extends DefaultFieldFactory {

    private final Class<T> beanType;
    
    public AddBeanFieldFactory(Class<T> type){
        this.beanType = type;
    }
    
    @Override
    public Field<?> createField(final Container container, final Object itemId,
            Object propertyId, final Component uiContext) {
        final Field<?> field = super.createField(container, itemId, propertyId, uiContext);
        if (field instanceof AbstractTextField) {
            ((AbstractTextField) field).setNullRepresentation("");
        }
        ((AbstractField<?>)field).setImmediate(true);
        field.addValueChangeListener(new ValueChangeListener() {
            
            @Override
            public void valueChange(ValueChangeEvent event) {
                Object lastItem = null;
                for (Object item : container.getItemIds()) {
                    lastItem = item;
                }
                if (itemId == lastItem && event.getProperty().getValue() != null) {
                    try {
                        ((Table)uiContext).addItem(beanType.newInstance());
                    } catch (Exception e) {
                        throw new RuntimeException("Can't create new object of type " + beanType.getName(), e);
                    }
                }
            }
        });
        return field;
    }
}