public static Constraint pattern ( final Object regex ) { return new Constraint ( "pattern" , patternPayload ( regex ) ) { public boolean isValid ( Object actualValue ) { if ( actualValue != null ) { if ( regex != null && regex instanceof String ) { if ( ! ( actualValue instanceof String ) || ! ( ( String ) actualValue ) . matches ( ( String ) regex ) ) { return false ; } } } return true ; } } ; }
The pattern constraint - field must contain a value matching a regular expression .