Search in sources :

Example 1 with FilledStringValidator

use of org.graylog2.database.validators.FilledStringValidator 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();
}
Also used : DateValidator(org.graylog2.database.validators.DateValidator) MapValidator(org.graylog2.database.validators.MapValidator) FilledStringValidator(org.graylog2.database.validators.FilledStringValidator) OptionalStringValidator(org.graylog2.database.validators.OptionalStringValidator) ImmutableMap(com.google.common.collect.ImmutableMap) OptionalStringValidator(org.graylog2.database.validators.OptionalStringValidator) Validator(org.graylog2.plugin.database.validators.Validator) MapValidator(org.graylog2.database.validators.MapValidator) DateValidator(org.graylog2.database.validators.DateValidator) FilledStringValidator(org.graylog2.database.validators.FilledStringValidator)

Example 2 with FilledStringValidator

use of org.graylog2.database.validators.FilledStringValidator in project graylog2-server by Graylog2.

the class StreamRuleImpl method getValidations.

@Override
public Map<String, Validator> getValidations() {
    final ImmutableMap.Builder<String, Validator> validators = ImmutableMap.builder();
    validators.put(FIELD_TYPE, new IntegerValidator());
    validators.put(FIELD_STREAM_ID, new ObjectIdValidator());
    validators.put(FIELD_CONTENT_PACK, new OptionalStringValidator());
    if (!EnumSet.of(StreamRuleType.ALWAYS_MATCH).contains(this.getType())) {
        validators.put(FIELD_FIELD, new FilledStringValidator());
    }
    if (!EnumSet.of(StreamRuleType.PRESENCE, StreamRuleType.ALWAYS_MATCH).contains(this.getType())) {
        validators.put(FIELD_VALUE, new FilledStringValidator());
    }
    return validators.build();
}
Also used : IntegerValidator(org.graylog2.database.validators.IntegerValidator) ObjectIdValidator(org.graylog2.database.validators.ObjectIdValidator) FilledStringValidator(org.graylog2.database.validators.FilledStringValidator) OptionalStringValidator(org.graylog2.database.validators.OptionalStringValidator) ImmutableMap(com.google.common.collect.ImmutableMap) OptionalStringValidator(org.graylog2.database.validators.OptionalStringValidator) Validator(org.graylog2.plugin.database.validators.Validator) IntegerValidator(org.graylog2.database.validators.IntegerValidator) ObjectIdValidator(org.graylog2.database.validators.ObjectIdValidator) FilledStringValidator(org.graylog2.database.validators.FilledStringValidator)

Example 3 with FilledStringValidator

use of org.graylog2.database.validators.FilledStringValidator in project graylog2-server by Graylog2.

the class FilledStringValidatorTest method testValidate.

@Test
public void testValidate() throws Exception {
    Validator v = new FilledStringValidator();
    assertFalse(v.validate(null).passed());
    assertFalse(v.validate(534).passed());
    assertFalse(v.validate("").passed());
    assertFalse(v.validate(new String()).passed());
    assertTrue(v.validate("so valid").passed());
}
Also used : Validator(org.graylog2.plugin.database.validators.Validator) Test(org.junit.Test)

Example 4 with FilledStringValidator

use of org.graylog2.database.validators.FilledStringValidator 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();
}
Also used : MapValidator(org.graylog2.database.validators.MapValidator) FilledStringValidator(org.graylog2.database.validators.FilledStringValidator) ImmutableMap(com.google.common.collect.ImmutableMap) OptionalStringValidator(org.graylog2.database.validators.OptionalStringValidator) Validator(org.graylog2.plugin.database.validators.Validator) MapValidator(org.graylog2.database.validators.MapValidator) DateValidator(org.graylog2.database.validators.DateValidator) FilledStringValidator(org.graylog2.database.validators.FilledStringValidator)

Example 5 with FilledStringValidator

use of org.graylog2.database.validators.FilledStringValidator in project graylog2-server by Graylog2.

the class AccessTokenImpl method getValidations.

@Override
public Map<String, Validator> getValidations() {
    Map<String, Validator> validations = Maps.newHashMap();
    validations.put(USERNAME, new FilledStringValidator());
    validations.put(TOKEN, new FilledStringValidator());
    validations.put(NAME, new FilledStringValidator());
    return validations;
}
Also used : FilledStringValidator(org.graylog2.database.validators.FilledStringValidator) Validator(org.graylog2.plugin.database.validators.Validator) FilledStringValidator(org.graylog2.database.validators.FilledStringValidator)

Aggregations

Validator (org.graylog2.plugin.database.validators.Validator)5 FilledStringValidator (org.graylog2.database.validators.FilledStringValidator)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 OptionalStringValidator (org.graylog2.database.validators.OptionalStringValidator)3 DateValidator (org.graylog2.database.validators.DateValidator)2 MapValidator (org.graylog2.database.validators.MapValidator)2 IntegerValidator (org.graylog2.database.validators.IntegerValidator)1 ObjectIdValidator (org.graylog2.database.validators.ObjectIdValidator)1 Test (org.junit.Test)1