Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Slice 3.0 introduces a simple validation mechanism which allows you to check if a model meets certain requirements or, in other words, is valid. Thanks to validation tag, a component whose model is not valid may not be displayed on a page.

Basic interfaces

The validation mechanism is based on two interfaces:

Validatable

If a class should be a subject to validation it should implement com.cognifide.slice.validation.api.Validatable. The interface introduces only one method: validate, which takes one argument: com.cognifide.slice.validation.api.ValidationResultBuilder. The argument allows you to define a validation messages of different levels. The types include:

  • error
  • warning
  • information

If at least one message has been added, the object is considered invalid. If there is no message, the object is considered valid.

Validator

The actual validation of an object is performed by com.cognifide.slice.validation.api.Validator interface. It defines one method: validate, which takes Validatable object as an argument. In result it returns ValidationResultValidationResult should be used for reading a result of validation and validation messages.

Validation tag

Blank values approach

  • No labels