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 Summary
Fields inherited from class io.jmix.flowui.component.validation.AbstractValidator
applicationContext, currentAuthentication, datatypeRegistry, defaultMessage, message, messages, substitutor
-
Constructor Summary
ConstructorDescriptionRegexpValidator
(String regexp) RegexpValidator
(String regexp, String message) Constructor for regexp value and custom error message. -
Method Summary
Methods inherited from class io.jmix.flowui.component.validation.AbstractValidator
afterPropertiesSet, fireValidationException, fireValidationException, formatValue, getMessage, getTemplateErrorMessage, setApplicationContext, setMessage
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.beans.factory.InitializingBean
afterPropertiesSet
-
Field Details
-
pattern
-
-
Constructor Details
-
RegexpValidator
-
RegexpValidator
Constructor for regexp value and custom error message. This message can contain '${value}' key for formatted output. Example: "Invalid value '${value}'".- Parameters:
regexp
- regular expressionmessage
- error message
-
-
Method Details
-
setRegexp
Sets regexp pattern value.- Parameters:
regexp
- a regexp pattern value
-
getRegexp
- Returns:
- a regexp pattern value
-
accept
Description copied from interface:Validator
Checks a value.
-