{@link ArrayFieldValidator} を追加する。
@param validator validatorのインスタンス。
@return 自身のインスタンス。
@throws NullPointerException validator is null.
173200
public ArrayCellField<E> add(final ArrayFieldValidator<E> validator) {
        ArgUtils.notNull(validator, "validator");
        this.arrayValidators.add(validator);

        return this;
    }
535360
public static void requireValid(@NotNull final Validator validator, @NotNull final Object value, @Nullable final Class<?>... groups)
            throws ConstraintViolationException {
        // CHECKSTYLE:ON

        final Set<ConstraintViolation<Object>> constraintViolations = validator.validate(value);
        if (constraintViolations.size() > 0) {
            final StringBuffer sb = new StringBuffer();
            for (final ConstraintViolation<Object> constraintViolation : constraintViolations) {
                if (sb.length() > 0) {
                    sb.append(", ");
                }
                sb.append("[" + constraintViolation.getPropertyPath() + "] " + constraintViolation.getMessage() + " {"
                        + constraintViolation.getInvalidValue() + "}");
            }
            throw new ConstraintViolationException(sb.toString(), constraintViolations);
        }

    }
35023
private void initValidation() {
        // Create validators and collect the results
        SimpleProperty<Result> resultCollector1 = new SimpleProperty<Result>();
        createValidator(textField1, new StickerFeedback(textField1), resultCollector1);
        SimpleProperty<Result> resultCollector2 = new SimpleProperty<Result>();
        createValidator(textField2, new ColorFeedback(textField2, false), resultCollector2);
        SimpleProperty<Result> resultCollector3 = new SimpleProperty<Result>();
        createValidator(textField3, new ColorFeedback(textField3, true), resultCollector3);
        SimpleProperty<Result> resultCollector4 = new SimpleProperty<Result>();
        createValidator(textField4, new IconFeedback(textField4, false), resultCollector4);
        SimpleProperty<Result> resultCollector5 = new SimpleProperty<Result>();
        createValidator(textField5, new IconFeedback(textField5, true), resultCollector5);

        // Enable Apply button only when all fields are valid
        read(resultCollector1, resultCollector2, resultCollector3, resultCollector4, resultCollector5) //
                .transform(new CollectionElementTransformer<Result, Boolean>(new ResultToBooleanTransformer())) //
                .transform(new AndBooleanAggregator()) //
                .write(new ComponentEnabledProperty(applyButton));
    }
110692
@Override
    public void validate(final FacesContext context) {
        if (context == null) {
            throw new NullPointerException();
        }

        final Validator[] validators = getValidators();
        final Object value = getValue();

        if (!validateRequired(context, value)) {
            return;
        }

        if (validators == null) {
            return;
        }

        for (final Validator validator : validators) {
            try {
                validator.validate(context, this, value);
            }
            catch (final ValidatorException ve) {
                // If the validator throws an exception, we're
                // invalid, and we need to add a message
                setValid(false);
                FacesMessage message;
                final String validatorMessageString = getValidatorMessage();

                if (null != validatorMessageString) {
                    message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
                                validatorMessageString,
                                validatorMessageString);
                    message.setSeverity(FacesMessage.SEVERITY_ERROR);
                }
                else {
                    final Collection<FacesMessage> messages = ve.getFacesMessages();
                    if (null != messages) {
                        message = null;
                        final String cid = getClientId(context);
                        for (final FacesMessage m : messages) {
                            context.addMessage(cid, m);
                        }
                    }
                    else {
                        message = ve.getFacesMessage();
                    }
                }
                if (message != null) {
                    final Sheet sheet = getSheet();
                    if (sheet == null) {
                        return;
                    }
                    context.addMessage(getClientId(context), message);
                    sheet.getInvalidUpdates().add(
                                new SheetInvalidUpdate(sheet.getRowKeyValue(context), sheet.getColumns().indexOf(this), this, value,
                                            message.getDetail()));

                }
            }
        }

    }
317003
public <T> FluentValidator on(T t, Validator<T> v) {
        Preconditions.checkNotNull(v, "Validator should not be NULL");
        composeIfPossible(v, t);
        doAdd(new ValidatorElement(t, v));
        lastAddCount = 1;
        return this;
    }
1032333
public static<E, T extends ParamValidator<E>> T getValidator(Class<T> clazz, Param<Boolean> param) {

        // get if such validator was already initialized
        List<ParamValidator> validators = validatorsMap.get(clazz);
        if (validators == null) {
            addValidators(validatorsMap, clazz, null, null);
        }

        // start searching from index 2 - from this index and on, the list preserves <ParamValidatorWrapper> specific instances
        for (int i=2; i<validators.size(); i++) {
            ParamValidator validator = validators.get(i);

            if (validator.getClass() == ParamValidatorWrapper.class &&
                ((ParamValidatorWrapper)validator).ifParam == param) {

                return (T)validator;
            }

        }

        T validator = (T)new ParamValidatorWrapper<E>(clazz, param);
        validators.add(validator);

        return validator;
    }
127060
public void annotateFieldJSR303(JMethod getter, boolean addValidAnnotation) {
		if (isRequired()) {
			getter.annotate(NotNull.class);
		}
		if (StringUtils.hasText(getPattern())) {
			JAnnotationUse annotation = getter.annotate(Pattern.class);
			annotation.param("regexp", getPattern());
		}
		if (getMinLength() != null || getMaxLength() != null) {
			JAnnotationUse annotation = getter.annotate(Size.class);

			if (getMinLength() != null) {
				annotation.param("min", getMinLength());
			}

			if (getMaxLength() != null) {
				annotation.param("max", getMaxLength());
			}
		}
		if (addValidAnnotation) {
			getter.annotate(Valid.class);
		}

		if (minimum != null) {
			JAnnotationUse annotation = getter.annotate(DecimalMin.class);
			annotation.param("value", String.valueOf(minimum));
		}

		if (maximum != null) {
			JAnnotationUse annotation = getter.annotate(DecimalMax.class);
			annotation.param("value", String.valueOf(maximum));
		}
	}
165617
@SuppressWarnings("deprecation")
    public void validate(final Mapper mapper) {
        new MappingValidator(mapper.getOptions().getObjectFactory()).validate(mapper, this);
    }
353858
private static MessageInterpolator getMessageInterpolatorFromValidator(Validator validator) {
        
        if(!(validator instanceof ValidatorImpl)) {
            return null;
        }
        
        try {
            Field field = ValidatorImpl.class.getDeclaredField("messageInterpolator");
            field.setAccessible(true);
            
            MessageInterpolator interpolator = (MessageInterpolator)field.get(validator);
            return interpolator;
            
        } catch (IllegalAccessException | NoSuchFieldException | SecurityException e) {
            throw new IllegalStateException("fail reflect MessageInterpolrator from ValidatorImpl.", e);
        }
        
    }
903891
public CellField<T> add(final List<FieldValidator<T>> validators) {

        if(validators.isEmpty()) {
            return this;
        }

        for(FieldValidator<T> validator : validators) {
            add(validator);
        }
        return this;
    }
322464
private void parseValidators(BeanDefinitionBuilder builder, Element element) {
        ManagedList validators = new ManagedList();
        for (Element validator : DomUtils.getChildElementsByTagName(element, "validator")) {

            if (validator.hasAttribute("ref")) {
                validators.add(new RuntimeBeanReference(validator.getAttribute("ref")));
            } else {
                validators.add(BeanDefinitionBuilder.rootBeanDefinition(validator.getAttribute("class")).getBeanDefinition());
            }
        }

        if (!validators.isEmpty()) {
            builder.addPropertyValue("messageValidators", validators);
        }
    }
124498
static String generateValidation(
            final Annotation annotation,
            final String checkType,
            final String checkName,
            final String fieldName) {

        if (VALIDATE_WITH_METHOD_CHECK.equals(checkType)) {
            // Special Case: Unwrap the check method and code generate its invocation
            final ValidateWithMethod validateWithMethod = (ValidateWithMethod) annotation;
            return "if (!(" + fieldName + " == null && " + checkName + ".isIgnoreIfNull()) && !"
                    + validateWithMethod.methodName() + "(" + fieldName + ")) {\n"
                    + "violations.add(new net.sf.oval.ConstraintViolation("
                    + checkName + ", " + checkName + ".getMessage(), this, " + fieldName + ", " + checkName + "_CONTEXT));\n"
                    + "}\n";
        } else if (FIELDS_EQUAL_CHECK.equals(checkType)) {
            // Special Case: Unwrap the other field reference and code generate its comparison
            // NOTE: This does not support getter usage.
            final EqualToField equalTo = (EqualToField) annotation;
            if (!equalTo.useGetter()) {
                return "if (" + fieldName + " != null && (" + equalTo.value() + " == null "
                        + "|| !" + fieldName + ".equals(" + equalTo.value() + "))) {\n"
                        + "violations.add(new net.sf.oval.ConstraintViolation("
                        + checkName + ", " + checkName + ".getMessage(), this, " + fieldName + ", " + checkName + "_CONTEXT));\n"
                        + "}\n";
            }
        } else if (FIELDS_NOT_EQUAL_CHECK.equals(checkType)) {
            // Special Case: Unwrap the other field reference and code generate its comparison
            // NOTE: This does not support getter usage.
            final NotEqualToField notEqualTo = (NotEqualToField) annotation;
            if (!notEqualTo.useGetter()) {
                return "if (" + fieldName + " != null && " + notEqualTo.value() + " != null "
                        + "&& " + fieldName + ".equals(" + notEqualTo.value() + ")) {\n"
                        + "violations.add(new net.sf.oval.ConstraintViolation("
                        + checkName + ", " + checkName + ".getMessage(), this, " + fieldName + ", " + checkName + "_CONTEXT));\n"
                        + "}\n";
            }
        }
        return "if (!" + checkName + ".isSatisfied(this, " + fieldName + ", null, null)) {\n"
                + "violations.add(new net.sf.oval.ConstraintViolation("
                + checkName + ", " + checkName + ".getMessage(), this, " + fieldName + ", " + checkName + "_CONTEXT));\n"
                + "}\n";
    }
1067547
@SuppressWarnings("unchecked")
    public void addValidator(CsvValidator<T>... validators ) {
        this.validators.addAll(Arrays.asList(validators));
    }
583980
public function addValidator(ValidatorInterface $validator)
    {
        $formDefinition = $this->getRootForm();
        $formDefinition->getProcessingRule($this->getIdentifier())->addValidator($validator);
    }
569822
protected boolean validate(JQMFormWidget widget) {

        boolean validated = true;
        Collection<Validator> validators = widgetValidators.get(widget);
        for (Validator v : validators)
            if (!validate(v, widget.asWidget()))
                validated = false;

        return validated;
    }
910084
private Validator getDefaultValidator(final FacesContext context) throws FacesException {
        if (!beanValidationPresent) {
            return null;
        }

        ValidatorFactory validatorFactory;
        Object cachedObject = context.getExternalContext().getApplicationMap().get(BeanValidator.VALIDATOR_FACTORY_KEY);
        if (cachedObject instanceof ValidatorFactory) {
            validatorFactory = (ValidatorFactory) cachedObject;
        } else {
            try {
                validatorFactory = Validation.buildDefaultValidatorFactory();
            } catch (ValidationException e) {
                throw new FacesException("Could not build a default Bean Validator factory", e);
            }
            context.getExternalContext().getApplicationMap().put(BeanValidator.VALIDATOR_FACTORY_KEY, validatorFactory);
        }
        return validatorFactory.getValidator();
    }
1361714
private void notifyOnValidationFailure(@NonNull final Validator<CharSequence> validator) {
        for (ValidationListener<CharSequence> validationListener : validationListeners) {
            validationListener.onValidationFailure(this, validator);
        }
    }