use of com.haulmont.cuba.gui.components.ValidationException in project cuba by cuba-platform.
the class DesktopDateField method validate.
@Override
public void validate() throws ValidationException {
if (!isVisible() || !isEditableWithParent() || !isEnabled())
return;
try {
constructDate();
super.validate();
} catch (RequiredValueMissingException e) {
throw e;
} catch (Exception e) {
throw new ValidationException(e);
}
}
use of com.haulmont.cuba.gui.components.ValidationException in project cuba by cuba-platform.
the class DateValidator method validate.
@Override
public void validate(Object value) throws ValidationException {
if (value == null)
return;
boolean result;
if (value instanceof String) {
try {
Datatype datatype = Datatypes.getNN(java.sql.Date.class);
UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME);
datatype.parse((String) value, sessionSource.getLocale());
result = true;
} catch (ParseException e) {
result = false;
}
} else {
result = value instanceof Date;
}
if (!result) {
String msg = message != null ? messages.getTools().loadString(messagesPack, message) : "Invalid value '%s'";
throw new ValidationException(String.format(msg, value));
}
}
use of com.haulmont.cuba.gui.components.ValidationException in project cuba by cuba-platform.
the class ScriptValidator method validate.
@Override
public void validate(Object value) throws ValidationException {
Boolean isValid = false;
if (params == null) {
params = new HashMap<>();
params.put("value", value);
} else {
params.put("value", value);
}
Scripting scripting = AppBeans.get(Scripting.NAME);
if (innerScript) {
isValid = scripting.evaluateGroovy(script, params);
} else if (scriptPath != null) {
isValid = scripting.runGroovyScript(scriptPath, params);
}
if (!isValid) {
String msg = message != null ? messages.getTools().loadString(messagesPack, message) : "Invalid value '%s'";
throw new ValidationException(String.format(msg, value));
}
}
Aggregations