/** * see AbstractValidator#onValidate(IValidatable) */ @Override protected void onValidate(IValidatable<String> validatable) { if ((validatable.getValue()).length() > maximum) { error(validatable); } }
/** * @param component * @param maxValue * @return */ public String maximumMessage(Component component, MaximumLengthValidator maximumLengthValidator) { String value = String.valueOf(maximumLengthValidator.getMaximum()); return addToBuffer( component.getId(), "maxlength|" + value, escapeJavaScriptString(formatMaximumMessage(component, "StringValidator.maximum", value))); }
/** * Gets a <code>String</code> maximum validator for checking if a string length is smaller than * the given maximum value. If that is not the case, then an error message will be generated * with the key "StringValidator.maximum". The message keys that can be used are: * <p> * <ul> * <li>${maximum}: the maximum 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 maximum * the maximum length of the string * * @return the requested <code>StringValidator</code> */ public static StringValidator maximumLength(int maximum) { return new MaximumLengthValidator(maximum); }
/** * Gets a <code>String</code> maximum validator for checking if a string length is smaller * than the given maximum value. If that is not the case, then an error message will be * generated with the key "StringValidator.maximum". The message keys that can be used are: * <p> * <ul> * <li>${maximum}: the maximum 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 maximum * the maximum length of the string * * @return the requested <code>StringValidator</code> */ public static StringValidator maximumLength(int maximum) { return new MaximumLengthValidator(maximum); }
/** * @param component * @param maxValue * @return */ public String maximumMessage(Component component, MaximumLengthValidator maximumLengthValidator) { String value = String.valueOf(maximumLengthValidator.getMaximum()); return addToBuffer( component.getId(), "maxlength|" + value, escapeJavaScriptString(formatMaximumMessage(component, "StringValidator.maximum", value))); }
/** * see AbstractValidator#onValidate(IValidatable) */ protected void onValidate(IValidatable validatable) { if (((String)validatable.getValue()).length() > maximum) { error(validatable); } }