Function: makeModelConstraints()
ts
function makeModelConstraints<Model>(
constraints: Record<StringKeyOf<Model>, Schema>,
strict: boolean,
): ModelConstraints<Model>;Creates a model validation constraints schema
Type Parameters
| Type Parameter |
|---|
Model extends PlainObject |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
constraints | Record<StringKeyOf<Model>, Schema> | undefined | An object where the keys are the model's properties and the values are the validation constraints |
strict | boolean | false | If true, the model will not allow any additional properties that are not defined in the constraints |
Returns
ModelConstraints<Model>
A Joi object schema that can be used to validate the model