Skip to main content
Version: 6.1

Validation

Entity.validate() is called during normalization and denormalization. undefined indicates no error, and a string error message if there is an error.

Field check

Validation happens after Entity.process() but before Entity.fromJS(), thus operates on POJOs rather than an instance of the class.

Here we can make sure the title field is included, and of the expected type.

Live Editor
Result
Loading...
Store

All fields check

Here's a recipe for checking that every defined field is present.

Live Editor
Result
Loading...
Store

Partial results

Another great use of validation is mixing endpoints that return incomplete objects. This is often useful when some fields consume lots of bandwidth or are computationally expensive for the backend.

Live Editor
Result
Loading...
Store