T
- any Object@Component(value="cuba_GroovyScriptValidator") @Scope(value="prototype") public class GroovyScriptValidator<T> extends AbstractValidator<T>
ValidationException
is thrown. scriptResult.toString()
is used as error message.
For error message it uses Groovy 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 web-spring.xml
,
for example:
<bean id="cuba_GroovyScriptValidator" class="com.haulmont.cuba.gui.components.validation.GroovyScriptValidator" scope="prototype"/>Use
BeanLocator
when creating the validator programmatically.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NAME |
protected Scripting |
scripting |
protected java.lang.String |
validatorGroovyScript |
datatypeRegistry, message, messages, userSessionSource
Constructor and Description |
---|
GroovyScriptValidator(java.lang.String validatorGroovyScript)
Constructor with default error message.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(T value) |
protected void |
fireValidationException(T value) |
protected void |
setDatatypeRegistry(DatatypeRegistry datatypeRegistry) |
protected void |
setMessages(Messages messages) |
protected void |
setUserSessionSource(UserSessionSource userSessionSource) |
formatValue, getMessage, getTemplateErrorMessage, setMessage
public static final java.lang.String NAME
@Inject protected Scripting scripting
protected java.lang.String validatorGroovyScript
public GroovyScriptValidator(java.lang.String validatorGroovyScript)
validatorGroovyScript
- groovy script with 'value' macro@Inject protected void setMessages(Messages messages)
@Inject protected void setDatatypeRegistry(DatatypeRegistry datatypeRegistry)
@Inject protected void setUserSessionSource(UserSessionSource userSessionSource)
public void accept(T value) throws ValidationException
ValidationException
protected void fireValidationException(T value)