@Retention(CLASS) @Target({FIELD})
public @interface Regex
Requires the component value to match a regular expression. The processor
emits a com.codename1.ui.validation.RegexConstraint(pattern, message)
into the Validator returned by Binding#getValidator().
@Bind(name="phoneField")
@Regex(pattern="^[0-9+\\-]+$", message="Digits, plus and dash only")
private String phone;
Use @Email or @Url for the two most common patterns – they reuse the
expressions already vetted in RegexConstraint.validEmail() /
validURL().
Methods
public abstract String pattern() | The regular expression. |
public abstract String message() default "Invalid value" | Override the default error message. |
Method details
pattern
public abstract String pattern()The regular expression. Same dialect as
com.codename1.util.regex.RE (a Codename One subset of standard
regex that works on every supported runtime).message
public abstract String message() default "Invalid value"Override the default error message. Required because
RegexConstraint has no canned message for arbitrary patterns.