Class RegexpValidator

    • Constructor Detail

      • RegexpValidator

        public RegexpValidator​(String errorMessage,
                               String regexp)
        Creates a validator for checking that the regular expression matches the complete string to validate.
        Parameters:
        errorMessage - the message to display in case the value does not validate.
        regexp - a Java regular expression
      • RegexpValidator

        public RegexpValidator​(String errorMessage,
                               String regexp,
                               boolean complete)
        Creates a validator for checking that the regular expression matches the string to validate.
        Parameters:
        errorMessage - the message to display in case the value does not validate.
        regexp - a Java regular expression
        complete - true to use check for a complete match, false to look for a matching substring
    • Method Detail

      • apply

        public ValidationResult apply​(String value,
                                      ValueContext context)
        Description copied from interface: Validator
        Validates the given value. Returns a ValidationResult instance representing the outcome of the validation.
        Parameters:
        value - the input value to validate
        context - the value context for validation
        Returns:
        the validation result
      • isValid

        protected boolean isValid​(String value)
        Returns whether the given string matches the regular expression.
        Parameters:
        value - the string to match
        Returns:
        true if the string matched, false otherwise