Skip to content

Field Validation

Taylor Wicksell edited this page May 2, 2017 · 5 revisions

Removed as of v1.17.0 as this feature was rarely used internally

Governator supports JSR 303 – Bean Validation by passing injected instances through the Hibernate Validator library.

All validation errors are thrown as the Governator exception: ValidationException

Example:

@Min(5)
private int   myInt;  // ValidationException is thrown if this is less than 5

Validation is performed when LifecycleManager.start() is called.

NOTE: You can combine validation, Auto Bind, Configuration, etc. annotations. E.g.

@Max(10)
@Configuration("my.config")
@AutoBind
@Inject
private int    myConfig = DEFAULT_VALUE;