Validate (and where sensible, coerce) a value against a field's declared type. Runs only
against values being written by insertEntity/updateEntity - it never re-validates data already
on disk, so a field whose declared type doesn't match its already-stored values (which can
happen, since nothing enforced this before) is left alone until something actually updates it.
An unrecognized type name is treated as unconstrained rather than rejected, so a typo in a
schema's field type can't silently block every write to that field.
A null is a real JSON null, kept as it is for a nullable field and rejected for any other, of
any type: it is never coerced, so a string field can't store the text "null" or an int field 0.
Parameters
type: string = 'string'
value: any = undefined
nullable: boolean = false
Whether the field may hold null (the field definition's nullable).
Validate (and where sensible, coerce) a value against a field's declared type. Runs only against values being written by insertEntity/updateEntity - it never re-validates data already on disk, so a field whose declared type doesn't match its already-stored values (which can happen, since nothing enforced this before) is left alone until something actually updates it. An unrecognized type name is treated as unconstrained rather than rejected, so a typo in a schema's field type can't silently block every write to that field.
A null is a real JSON null, kept as it is for a nullable field and rejected for any other, of any type: it is never coerced, so a string field can't store the text "null" or an int field 0.