Class RegexpValidator

java.lang.Object
io.jmix.flowui.component.validation.AbstractValidator<String>
io.jmix.flowui.component.validation.RegexpValidator
All Implemented Interfaces:
Validator<String>, Consumer<String>, org.springframework.beans.factory.Aware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware

@Component("flowui_RegexpValidator") @Scope("prototype") public class RegexpValidator extends AbstractValidator<String> implements org.springframework.beans.factory.InitializingBean
Regexp validator checks that String value is matched with specified regular expression.

The regular expression follows the Java regular expression conventions.

For error message it uses template string and it is possible to use '${value}' key for formatted output.

In order to provide your own implementation globally, create a subclass and register it in configuration class, for example:

     @Bean("flowui_RegexpValidator")
     @Scope(BeanDefinition.SCOPE_PROTOTYPE)
     @Primary
     protected RegexpValidator regexpValidator(String regexp) {
          return new CustomRegexpValidator(regexp);
     }
 
See Also:
  • Field Details

    • pattern

      protected Pattern pattern
  • Constructor Details

    • RegexpValidator

      public RegexpValidator(String regexp)
    • RegexpValidator

      public RegexpValidator(String regexp, String message)
      Constructor for regexp value and custom error message. This message can contain '${value}' key for formatted output. Example: "Invalid value '${value}'".
      Parameters:
      regexp - regular expression
      message - error message
  • Method Details