Validation
Formn offers some built-in validation classes that can be used prior to inserting, updating, or deleteing records. These classes build on top of the bsy-validation package, which provides decorator-based validation, and is extendable.
Formn models (see the Models section) have a good deal of column
metadata that’s provided using the
Column decorator. This metadata
includes data type, nullability, max length requirements, and so on. With that
metadata, Formn can verify that user-provided models meet the criteria needed
to insert, update, or delete records. For example, if a database table has a
phoneNumber VARCHAR(255) NOT NULL
column, a corresponding Formn model cannot
be inserted if the phoneNumber
property is null
, undefined
, not a
string
, or exceeds 255 characters. But when updating, the validation rules
differ: phoneNumber
doesn’t have to be defined.
These metadata verifications, coupled with bsy-validation, provide an extensive validation suite.