/** * see AbstractValidator#onValidate(IValidatable) */ @Override protected void onValidate(IValidatable<String> validatable) { if ((validatable.getValue()).length() < minimum) { error(validatable); } }
/** * Gets a <code>String</code> minimum validator for checking if a string length is greater than * the given minimum value. If that is not the case, then an error message will be generated * with the key "StringValidator.minimum". The message keys that can be used are: * <p> * <ul> * <li>${minimum}: the minimum length</li> * <li>${length}: the length of the user input</li> * <li>${input}: the input the user gave</li> * <li>${name}: the name of the <code>Component</code> that failed</li> * <li>${label}: the label of the <code>Component</code> - either comes from * <code>FormComponent.labelModel</code> or resource key [form-id].[form-component-id] in that * order</li> * </ul> * * @param minimum * the minimum length of the string * * @return the requested <code>StringValidator</code> */ public static StringValidator minimumLength(int minimum) { return new MinimumLengthValidator(minimum); } }
/** * Gets a <code>String</code> minimum validator for checking if a string length is greater * than the given minimum value. If that is not the case, then an error message will be * generated with the key "StringValidator.minimum". The message keys that can be used are: * <p> * <ul> * <li>${minimum}: the minimum length</li> * <li>${length}: the length of the user input</li> * <li>${input}: the input the user gave</li> * <li>${name}: the name of the <code>Component</code> that failed</li> * <li>${label}: the label of the <code>Component</code> - either comes from * <code>FormComponent.labelModel</code> or resource key [form-id].[form-component-id] in that * order</li> * </ul> * * @param minimum * the minimum length of the string * * @return the requested <code>StringValidator</code> */ public static StringValidator minimumLength(int minimum) { return new MinimumLengthValidator(minimum); } }
/** * @param component * @param minimumLengthValidator * @return */ public String minimumMessage(Component component, MinimumLengthValidator minimumLengthValidator) { String value = String.valueOf(minimumLengthValidator.getMinimum()); return addToBuffer( component.getId(), "minlength|" + value, escapeJavaScriptString(formatMinimumMessage(component, "StringValidator.minimum", value))); }
/** * @param component * @param minimumLengthValidator * @return */ public String minimumMessage(Component component, MinimumLengthValidator minimumLengthValidator) { String value = String.valueOf(minimumLengthValidator.getMinimum()); return addToBuffer( component.getId(), "minlength|" + value, escapeJavaScriptString(formatMinimumMessage(component, "StringValidator.minimum", value))); }
/** * see AbstractValidator#onValidate(IValidatable) */ protected void onValidate(IValidatable validatable) { if (((String)validatable.getValue()).length() < minimum) { error(validatable); } }