schema.constraints.md

January 18, 2023 ยท View on GitHub

Home > @datashaper/schema > Constraints

Constraints interface

Validation constraints for a field.

Signature:

export interface Constraints 

Properties

PropertyModifiersTypeDescription
enum?string[](Optional) Strict list of allowed values in the column.
maximum?number(Optional) For numbers or dates, this is the maximum allowed value.
maxLength?number(Optional) For strings or arrays, this is the maximum allowed length of values.
minimum?number(Optional) For numbers or dates, this is the minimum allowed value.
minLength?number(Optional) For strings or arrays, this is the minimum allowed length of values.
pattern?string(Optional) RegExp pattern that string values must match.
required?boolean(Optional) Indicates that this field is required (not nullable).
unique?boolean(Optional) Indicates that every value in this column must be unique.