use of com.enonic.xp.schema.content.validator.ContentTypeValidationError in project xp by enonic.
the class ContentTypeSuperTypeValidator method validate.
public void validate(final ContentTypeName contentTypeName, final ContentTypeName superTypeContentName) {
if (superTypeContentName != null) {
final GetContentTypeParams params = new GetContentTypeParams().contentTypeName(superTypeContentName);
final ContentType superType = contentTypeService.getByName(params);
if (superType == null) {
registerError(new ContentTypeValidationError("superType not found: " + superTypeContentName, contentTypeName));
return;
}
if (superType.isFinal()) {
registerError(new ContentTypeValidationError("Cannot inherit from a final ContentType: " + superType.getName(), contentTypeName));
}
}
}
use of com.enonic.xp.schema.content.validator.ContentTypeValidationError in project xp by enonic.
the class SuperTypeValidatorTest method validationResult.
@Test
public void validationResult() {
ContentTypeValidationResult validationResult1 = ContentTypeValidationResult.from(new ContentTypeValidationError("superType not found: superTypeName", ContentTypeName.media()));
ContentTypeValidationResult validationResult2 = ContentTypeValidationResult.from(Collections.singleton(new ContentTypeValidationError("superType not found: superTypeName", ContentTypeName.media())));
ContentTypeValidationResult validationResult3 = ContentTypeValidationResult.empty();
assertNotEquals(validationResult1, validationResult2);
assertNotEquals(validationResult1.hashCode(), validationResult2.hashCode());
assertFalse(validationResult3.hasErrors());
assertNotEquals(validationResult2.hashCode(), validationResult3.hashCode());
assertNotEquals(validationResult2.toString(), validationResult3.toString());
}
Aggregations