Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
RAVE's generated validator code.
public final class RaveValidatorFactory_Generated_Validator extends BaseValidator {
RaveValidatorFactory_Generated_Validator() {
protected void validateAs(@NonNull Object object, @NonNull Class<?> clazz, @NonNull ExclusionStrategy exclusionStrategy) throws InvalidModelException {
if (!clazz.isInstance(object)) {
throw new IllegalArgumentException(object.getClass().getCanonicalName() + "is not of type" + clazz.getCanonicalName());
if (clazz.equals(MyModel.class)) {
validateAs((MyModel) object, exclusionStrategy);
throw new IllegalArgumentException(object.getClass().getCanonicalName() + " is not supported by validator " + this.getClass().getCanonicalName());
private void validateAs(MyModel object, ExclusionStrategy exclusionStrategy) throws InvalidModelException {
BaseValidator.ValidationContext context = getValidationContext(MyModel.class);
List<RaveError> raveErrors = null;
if (!setContextAndCheckshouldIgnoreMethod(MyModel.class, "getSomeString", exclusionStrategy, context)) {
raveErrors = mergeErrors(raveErrors, checkNullable(object.getSomeString(), false, context));
if (!setContextAndCheckshouldIgnoreMethod(MyModel.class, "customValidationLogic", exclusionStrategy, context)) {
raveErrors = mergeErrors(raveErrors, mustBeTrue(object.customValidationLogic(), context));
if (raveErrors != null && !raveErrors.isEmpty()) {
throw new InvalidModelException(raveErrors);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment