use of org.graylog2.database.validators.DateValidator in project graylog2-server by Graylog2.
the class InputImpl method getValidations.
@Override
public Map<String, Validator> getValidations() {
final ImmutableMap.Builder<String, Validator> validations = ImmutableMap.builder();
//validations.put(MessageInput.FIELD_INPUT_ID, new FilledStringValidator());
validations.put(MessageInput.FIELD_TITLE, new FilledStringValidator());
validations.put(MessageInput.FIELD_TYPE, new FilledStringValidator());
validations.put(MessageInput.FIELD_CONFIGURATION, new MapValidator());
validations.put(MessageInput.FIELD_CREATOR_USER_ID, new FilledStringValidator());
validations.put(MessageInput.FIELD_CREATED_AT, new DateValidator());
validations.put(MessageInput.FIELD_CONTENT_PACK, new OptionalStringValidator());
return validations.build();
}
use of org.graylog2.database.validators.DateValidator in project graylog2-server by Graylog2.
the class DateValidatorTest method testValidate.
@Test
public void testValidate() throws Exception {
Validator v = new DateValidator();
assertFalse(v.validate(null).passed());
assertFalse(v.validate(9001).passed());
assertFalse(v.validate("").passed());
assertFalse(v.validate(new java.util.Date()).passed());
// Only joda datetime.
assertTrue(v.validate(new org.joda.time.DateTime(DateTimeZone.UTC)).passed());
// Only accepts UTC.
assertFalse(v.validate(new org.joda.time.DateTime(DateTimeZone.forID("+09:00"))).passed());
}
Aggregations