use of org.graylog2.database.validators.MapValidator 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.MapValidator in project graylog2-server by Graylog2.
the class InputImpl method getEmbeddedValidations.
@Override
public Map<String, Validator> getEmbeddedValidations(String key) {
if (EMBEDDED_EXTRACTORS.equals(key)) {
final ImmutableMap.Builder<String, Validator> validations = ImmutableMap.builder();
validations.put(Extractor.FIELD_ID, new FilledStringValidator());
validations.put(Extractor.FIELD_TITLE, new FilledStringValidator());
validations.put(Extractor.FIELD_TYPE, new FilledStringValidator());
validations.put(Extractor.FIELD_CURSOR_STRATEGY, new FilledStringValidator());
validations.put(Extractor.FIELD_TARGET_FIELD, new FilledStringValidator());
validations.put(Extractor.FIELD_SOURCE_FIELD, new FilledStringValidator());
validations.put(Extractor.FIELD_CREATOR_USER_ID, new FilledStringValidator());
validations.put(Extractor.FIELD_EXTRACTOR_CONFIG, new MapValidator());
return validations.build();
}
if (EMBEDDED_STATIC_FIELDS.equals(key)) {
return ImmutableMap.of(FIELD_STATIC_FIELD_KEY, new FilledStringValidator(), FIELD_STATIC_FIELD_VALUE, new FilledStringValidator());
}
return Collections.emptyMap();
}
use of org.graylog2.database.validators.MapValidator in project graylog2-server by Graylog2.
the class MapValidatorTest method testValidate.
@Test
public void testValidate() throws Exception {
Validator v = new MapValidator();
assertFalse(v.validate(null).passed());
assertFalse(v.validate(new LinkedList<Integer>()).passed());
assertFalse(v.validate(9001).passed());
assertFalse(v.validate("foo").passed());
Map<String, String> actuallyFilledMap = new TreeMap<String, String>();
actuallyFilledMap.put("foo", "bar");
actuallyFilledMap.put("lol", "wut");
assertTrue(v.validate(actuallyFilledMap).passed());
assertTrue(v.validate(new HashMap<String, String>()).passed());
}
Aggregations