@Scope(value="prototype") @Component(value="ui_RegexpValidator") public class RegexpValidator extends AbstractValidator<java.lang.String>
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("ui_RegexpValidator") @Scope(BeanDefinition.SCOPE_PROTOTYPE) @Primary protected RegexpValidator regexpValidator(String regexp) { return new CustomRegexpValidator(regexp); }
Pattern
Modifier and Type | Field and Description |
---|---|
protected java.util.regex.Pattern |
pattern |
currentAuthentication, datatypeRegistry, message, messages, substitutor
Constructor and Description |
---|
RegexpValidator(java.lang.String regexp) |
RegexpValidator(java.lang.String regexp,
java.lang.String message)
Constructor for regexp value and custom error message.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(java.lang.String value)
Checks a value.
|
java.lang.String |
getRegexp() |
protected void |
setMessages(io.jmix.core.Messages messages) |
void |
setRegexp(java.lang.String regexp)
Sets regexp pattern value.
|
void |
setStringSubstitutor(StringSubstitutor substitutor) |
formatValue, getMessage, getTemplateErrorMessage, setMessage
public RegexpValidator(java.lang.String regexp)
public RegexpValidator(java.lang.String regexp, java.lang.String message)
regexp
- regular expressionmessage
- error message@Autowired protected void setMessages(io.jmix.core.Messages messages)
@Autowired public void setStringSubstitutor(StringSubstitutor substitutor)
@StudioProperty(required=true) public void setRegexp(java.lang.String regexp)
regexp
- a regexp pattern valuepublic java.lang.String getRegexp()
public void accept(java.lang.String value) throws ValidationException
Validator
value
- a valueValidationException