Server Error Messages

FormStore supports server.set/create returning a response object with error information in this format:

Property Data type Description
status String Must be 'error' to enable the processing of error message(s).
error String or Object If a string, it is placed into model.serverError and it will be the first element ofthe model.status.errors Array. (A typical use case is a general error like failed authentication). If an object, it's copied over to model.dataErrors, so this allows the server to return validation errors for each data property.
error_field String or Array of Strings Optional. Either a single field name as a string or an array of field names also considered in error. Any such field that does not have something in dataErrors[name] (after copying error object above) will be reverted to a known-good value if auto-save is enabled.

The combined list of fields in error (error object keys and field(s) in error_field) are fields that the server designated as being in error. Therefore, the updated value of each field in this list is NOT placed into the saved/known-good data in the model, like it normally happens at the end of a successful save().

Using error codes and client-side validation message formatting

For each property in error, instead of returning a String, the server can return an object in tv4 validation error format, i.e. with code and optional message property. When using MobxSchemaForm, such objects will be converted into messages using templates defined for the code in validationMessage property in that field's Form Field Metadata (or options.formDefaults passed to MobxSchemaForm).

results matching ""

    No results matching ""