use of io.atlasmap.v2.ValidationStatus in project atlasmap by atlasmap.
the class StringLengthValidator method validate.
@Override
public void validate(Object target, List<Validation> validations, String id, ValidationStatus status) {
String value = (String) target;
if (value.isEmpty() || value.length() > maxLength || value.length() < minLength) {
Validation validation = new Validation();
validation.setScope(scope);
validation.setId(id);
validation.setMessage(String.format(violationMessage, target.toString()));
validation.setStatus(status);
validations.add(validation);
}
}
use of io.atlasmap.v2.ValidationStatus in project atlasmap by atlasmap.
the class StringPatternValidator method validate.
@Override
public void validate(Object target, List<Validation> validations, String id, ValidationStatus status) {
Pattern regEx = Pattern.compile(pattern);
if (target != null && supports(target.getClass())) {
String value = (String) target;
Matcher m = regEx.matcher(value);
if (useMatch) {
if (!m.matches()) {
Validation validation = new Validation();
validation.setScope(scope);
validation.setId(id);
validation.setMessage(String.format(violationMessage, target.toString()));
validation.setStatus(status);
validations.add(validation);
}
} else {
if (m.find()) {
Validation validation = new Validation();
validation.setScope(scope);
validation.setId(id);
validation.setMessage(String.format(violationMessage, target.toString()));
validation.setStatus(status);
validations.add(validation);
}
}
}
}
use of io.atlasmap.v2.ValidationStatus in project atlasmap by atlasmap.
the class LookupTableNameValidator method validate.
@Override
public void validate(Object target, List<Validation> validations, String id, ValidationStatus status) {
LookupTables lookupTables = (LookupTables) target;
List<LookupTable> tables = lookupTables.getLookupTable();
List<LookupTable> deduped = Collections.unmodifiableList(tables).stream().filter(distinctByKey(LookupTable::getName)).collect(Collectors.toList());
if (deduped.size() != tables.size()) {
String dupedName = findDuplicatedName(tables);
Validation validation = new Validation();
validation.setScope(ValidationScope.LOOKUP_TABLE);
validation.setId(id);
validation.setMessage(String.format(violationMessage, dupedName));
validation.setStatus(status);
validations.add(validation);
}
}
use of io.atlasmap.v2.ValidationStatus in project atlasmap by atlasmap.
the class NonNullValidator method validate.
@Override
public void validate(Object target, List<Validation> validations, String id, ValidationStatus status) {
if (target == null) {
Validation validation = new Validation();
validation.setScope(scope);
validation.setId(id);
validation.setMessage(violationMessage);
validation.setStatus(status);
validations.add(validation);
} else if (target.getClass().isAssignableFrom(String.class)) {
String value = (String) target;
if (value.trim().isEmpty()) {
// TODO: Add support for target value
Validation validation = new Validation();
validation.setScope(scope);
validation.setId(id);
validation.setMessage(violationMessage);
validation.setStatus(status);
validations.add(validation);
}
}
}
use of io.atlasmap.v2.ValidationStatus in project atlasmap by atlasmap.
the class NotEmptyValidator method validate.
@Override
public void validate(Object target, List<Validation> validations, String id, ValidationStatus status) {
if (!supports(target)) {
return;
}
if (((Collection<?>) target).isEmpty()) {
Validation validation = new Validation();
validation.setScope(scope);
validation.setId(id);
validation.setMessage(this.violationMessage);
validation.setStatus(status);
validations.add(validation);
}
}
Aggregations