Validators.
The in-built validators are designed to ensure that as few errors as possible are allowed through the generation. Whilst the .h2zero file may be syntactically valid, these validators will help with the generated code.
When the .h2zero file has been successfully parsed and processed, validators are run across the java model to ensure that the generated code will be as free from errors as possible.
Validation error levels
Validators will log to the console three different types of messages.
INFO
- Informational messages that do not affect the h2zero generation.
WARN
- Warning messages that should be cleared when next editing the
.h2zero
file. This may also include deprecation messages. These messages will not affect the successful generation of the .h2zero artifacts. FATAL
- Fatal messages that will stop the generation of the .h2zero artifacts. These MUST be fixed before the code can be generated.
Validator list
Some of the in-built validators that exist within the h2zero project are as follows:
DefaultValueValidator.java
- Ensure that the defaultValue field is enclosed within single quotation marks (')
FieldNameDuplicateValidator.java
- Ensure that there are no duplicate field names
ForeignKeyTableValidator.java
- Ensure that the foreign key table exists
TableNameDuplicateValidator.java
- Ensure that there are no duplicate tables
UniqeAndIndexValidator.java
- Warnings where a field is both unique and indexed - which is redundant.
ConstantTableValidator.java
- Ensure that the generation of constants have unique primary keys and names
CounterJsonUniqueKeyExistsValidator.java
- Warnings where a counter has a unique key, which is ignored
FinderAutoIndexValidator.java
- Warnings for automatically generated finders that are neither marked as unique nor indexed which may slow down database lookups
FinderQueryParameterNumberValidator.java
- Ensure that the number of parameters in the SQL whereClause has associated fields of the correct type in the whereClause
FinderWhereClauseValidator.java
- Automatically add a 'where' string to the whereClause if it does not already start with one
FinderWhereFieldAliasValidator.java
- Ensure that aliased whereFields have an alias attached to them
QuestionJsonUniqueKeyExistsValidator.java
- Warnings where a question has a unique key, which is ignored
TableDeprecatedFinderKeyValidator.java
- Deprecation warnings for fields that have a JSON key of 'finder'
TableDeprecatedForeignKeyValidator.java
- Deprecation warnings for fields that have a JSON key of 'foreign'
TablePrimaryKeyExistsValidator.java
- Ensure every table has a primary key.
TablePrimaryKeyNameValidator.java
- Warnings where the primary key is not of the form id_>table_name< for a table
TablePrimaryKeyTypeValidator.java
- Ensure that the primary key is always of type bigint