Validator for field in table

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.addItem(new EnumValueDescriptor());
        table.setTableFieldFactory(new AddBeanFieldFactory<EnumValueDescriptor>(EnumValueDescriptor.class){
            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 {
                } catch (SQLException e) {
                    // should not happen, if yes --> no validation against the database
                return field;

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.
public class AddBeanFieldFactory<T> extends DefaultFieldFactory {

    private final Class<T> beanType;
    public AddBeanFieldFactory(Class<T> type){
        this.beanType = type;
    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("");
        field.addValueChangeListener(new ValueChangeListener() {
            public void valueChange(ValueChangeEvent event) {
                Object lastItem = null;
                for (Object item : container.getItemIds()) {
                    lastItem = item;
                if (itemId == lastItem && event.getProperty().getValue() != null) {
                    try {
                    } catch (Exception e) {
                        throw new RuntimeException("Can't create new object of type " + beanType.getName(), e);
        return field;