com.kenshoo.pl.entity.spi.FieldValidator Maven / Gradle / Ivy
                 Go to download
                
        
                    Show more of this group  Show more artifacts with this name
Show all versions of persistence-layer Show documentation
                Show all versions of persistence-layer Show documentation
A Java persistence layer based on JOOQ for high performance and business flow support.
                
             The newest version!
        
        package com.kenshoo.pl.entity.spi;
import com.kenshoo.pl.entity.*;
import java.util.function.Predicate;
import java.util.stream.Stream;
/**
 * The simplest form of a validator - validates a single field value without using any external information.
 * For example, may be used to validate that the value of a field is positive.
 *
 * @param  entity type
 * @param  type of the validated field
 */
public interface FieldValidator, T> extends ChangeValidator {
    /**
     * @return the field validated by the validator
     */
    EntityField validatedField();
    /**
     * Validates the new field value.
     *
     * @param fieldValue new value of the field
     * @return validation error or null if none
     */
    ValidationError validate(T fieldValue);
    /**
     * @return a list of fields to fetch. May contain fields of parent entities only
     */
    default Stream> fetchFields() {
        return Stream.of();
    }
    /**
     * The predicate is evaluated on the final state of the entity See {@link FinalEntityState}.
     * @return a predicate indicating when the field should be validated. It will be evaluated together with {@link #fetchFields()},
     * which means that all the fields appearing in the predicate must also be included in the fields to fetch or be required
     * for create operation
     */
    default Predicate validateWhen() {
        return e -> true;
    }
}
          © 2015 - 2025 Weber Informatics LLC | Privacy Policy