Skip to content

v5.4.0

Choose a tag to compare

@github-actions github-actions released this 21 Oct 16:12
· 234 commits to main since this release

See Upgrading to 5.4 for what apps need to
change.

Behaviour changes

  • server: Validation errors carry the messages of @ditojs/schema that the admin shows, instead of Ajv's, e.g. "must be 5 or more" instead of "must be >= 5". Their keyword and params stay the same: clients that match message texts need to match those instead.
  • admin: Several fields of the same value, e.g. in two tabs, take each aspect, e.g. default or serializeValue(), from the first field in form order that defines it. All of them validate the value, and items are sent with the values of all their forms.
  • admin: Validation follows the server, with the definitions of @ditojs/schema:
    • maxLength is validated, counted in characters, not only set as the maxlength of inputs: saving fails where code wrote longer values.
    • required accepts empty arrays, except on types whose empty value is an array, e.g. lists, checkboxes, multiselects and uploads with multiple.
    • minimum, maximum and range only apply to numbers.
    • url fields require a scheme: example.com fails, https://example.com passes.
    • date, datetime and time fields reject invalid dates, e.g. new Date('soon') or '14:30', with "must be a valid date".
    • select, multiselect, radio and checkboxes with options given as an array reject values missing from them, with "must be one of the options". Options from callbacks or dataPath, and multiselects with taggable or search, still accept them.
    • integer says "must be a whole number", and decimals e.g. "must be a number with at most 2 decimal places".
  • admin: Empty values: markup stores an empty editor as null instead of e.g. <p></p>, code sends null instead of '' when emptied, and upload with multiple holds [] instead of null while it has no value.

Deprecations

  • server: app.compileValidator() is deprecated in favour of app.compileJsonSchema().
  • admin: The rules of fields are deprecated: use field keys for limits, e.g. minimum or maxLength, the type for type checks, and validate() for the rest, see Types and limits of fields.
  • admin: min and max of number types are deprecated aliases of minimum and maximum. Custom types return minimum and maximum from getValidations().

New

  • server: app.compileDitoSchema() compiles schemas in the format of model properties, and app.compileJsonSchema() plain JSON schemas, see Validation.
  • admin: context.getErrors(match?) returns the errors of the data by data path, e.g. for the markup of useDitoForm() pages.
  • admin: Fields take minLength, pattern, minItems and maxItems, and number types minimum and maximum, as the server's model properties do.
  • admin: nullable: false on string fields and checkbox stores no value as '' or false instead of null.
  • schema: New package @ditojs/schema with the formats and keywords that the server and the admin share.

Fixes

  • admin, forms:
    • Leaving a form with unsaved changes asks "Do you want to discard them?" instead of "Do you really want to cancel?".
    • Edits of fields in the panels of lists and other sources mark the form as unsaved.
    • Values merged into the data, e.g. with context.mergeItem(), replace the errors of fields in panels too.
  • admin, fields: Clear buttons don't show for ''.