use of liquibase.exception.ValidationErrors in project liquibase by liquibase.
the class AddDefaultValueChange method validate.
@Override
public ValidationErrors validate(Database database) {
ValidationErrors validate = new ValidationErrors();
int nonNullValues = 0;
if (defaultValue != null) {
nonNullValues++;
}
if (defaultValueNumeric != null) {
nonNullValues++;
}
if (defaultValueBoolean != null) {
nonNullValues++;
}
if (defaultValueDate != null) {
nonNullValues++;
}
if (defaultValueComputed != null) {
nonNullValues++;
}
if (defaultValueSequenceNext != null) {
nonNullValues++;
}
if (nonNullValues > 1) {
validate.addError("Only one defaultValue* value can be specified");
} else {
validate.addAll(super.validate(database));
}
return validate;
}
use of liquibase.exception.ValidationErrors in project liquibase by liquibase.
the class DropColumnChange method validate.
@Override
public ValidationErrors validate(Database database) {
if (database instanceof SQLiteDatabase) {
ValidationErrors validationErrors = new ValidationErrors();
validationErrors.checkRequiredField("tableName", tableName);
validationErrors.checkRequiredField("columnName", columnName);
return validationErrors;
}
return super.validate(database);
}
use of liquibase.exception.ValidationErrors in project liquibase by liquibase.
the class OutputChange method validate.
@Override
public ValidationErrors validate(Database database) {
ValidationErrors validate = super.validate(database);
validate.checkRequiredField("message", getMessage());
return validate;
}
use of liquibase.exception.ValidationErrors in project liquibase by liquibase.
the class ValidatingVisitorTest method visit_validateError.
@Test
public void visit_validateError() throws Exception {
changeSet1.addChange(new CreateTableChange() {
@Override
public ValidationErrors validate(Database database) {
ValidationErrors changeValidationErrors = new ValidationErrors();
changeValidationErrors.addError("Test message");
return changeValidationErrors;
}
});
List<RanChangeSet> ran = new ArrayList<RanChangeSet>();
ValidatingVisitor handler = new ValidatingVisitor(ran);
handler.visit(changeSet1, new DatabaseChangeLog(), null, null);
assertEquals(1, handler.getValidationErrors().getErrorMessages().size());
assertTrue(handler.getValidationErrors().getErrorMessages().get(0).startsWith("Test message"));
assertFalse(handler.validationPassed());
}
use of liquibase.exception.ValidationErrors in project liquibase by liquibase.
the class AddForeignKeyConstraintGenerator method validate.
@Override
public ValidationErrors validate(AddForeignKeyConstraintStatement addForeignKeyConstraintStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
ValidationErrors validationErrors = new ValidationErrors();
if ((addForeignKeyConstraintStatement.isInitiallyDeferred() || addForeignKeyConstraintStatement.isDeferrable()) && !database.supportsInitiallyDeferrableColumns()) {
validationErrors.checkDisallowedField("initiallyDeferred", addForeignKeyConstraintStatement.isInitiallyDeferred(), database);
validationErrors.checkDisallowedField("deferrable", addForeignKeyConstraintStatement.isDeferrable(), database);
}
validationErrors.checkRequiredField("baseColumnNames", addForeignKeyConstraintStatement.getBaseColumnNames());
validationErrors.checkRequiredField("baseTableNames", addForeignKeyConstraintStatement.getBaseTableName());
validationErrors.checkRequiredField("referencedColumnNames", addForeignKeyConstraintStatement.getReferencedColumnNames());
validationErrors.checkRequiredField("referencedTableName", addForeignKeyConstraintStatement.getReferencedTableName());
validationErrors.checkRequiredField("constraintName", addForeignKeyConstraintStatement.getConstraintName());
validationErrors.checkDisallowedField("onDelete", addForeignKeyConstraintStatement.getOnDelete(), database, SybaseDatabase.class);
return validationErrors;
}
Aggregations