Skip to content

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

ParameterTypeDefault valueDescription
constraintsRecord<StringKeyOf<Model>, Schema>undefinedAn object where the keys are the model's properties and the values are the validation constraints
strictbooleanfalseIf 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