/** * Tests the current value against registered validators if the field is not * empty. If the field is empty it is considered valid if it is not required * and invalid otherwise. Validators are never checked for empty fields. * * In most cases, {@link #validate()} should be used instead of * {@link #isValid()} to also get the error message. * * @return <code>true</code> if all registered validators claim that the * current value is valid or if the field is empty and not required, * <code>false</code> otherwise. */ @Override public boolean isValid() { try { validate(); return true; } catch (InvalidValueException e) { return false; } }
/** * Checks the validity of the Form and all of its fields. * * @see Validatable#validate() */ @Override public void validate() throws InvalidValueException { super.validate(); for (final Object id : propertyIds) { fields.get(id).validate(); } }
/** * Validates the current value against registered validators if the field is * not empty. Note that DateField is considered empty (value == null) and * invalid if it contains text typed in by the user that couldn't be parsed * into a Date value. * * @see AbstractField#validate() */ @Override public void validate() throws InvalidValueException { /* * To work properly in form we must throw exception if there is * currently a parsing error in the datefield. Parsing error is kind of * an internal validator. */ if (!uiHasValidDateString) { throw new UnparsableDateString(currentParseErrorMessage); } super.validate(); }
/** * Checks the validity of the Field. * * A field is invalid if it is set as required (using * {@link #setRequired(boolean)} and is empty, if one or several of the * validators added to the field indicate it is invalid or if the value * cannot be converted provided a converter has been set. * * The "required" validation is a built-in validation feature. If the field * is required and empty this method throws an EmptyValueException with the * error message set using {@link #setRequiredError(String)}. * * @see Validatable#validate() */ @Override public void validate() throws Validator.InvalidValueException { if (isRequired() && isEmpty()) { throw new Validator.EmptyValueException(requiredError); } validate(getFieldValue()); }
if (isValidationVisible()) { try { validate(); } catch (Validator.InvalidValueException e) { if (!e.isInvisible()) {
validate(newFieldValue);