Table of contents

Public class

Signature
class ObjectValidator<Shape extends object> extends Validator<Shape> {}
References

Validator

Source

packages/validate/src/lib/validation.ts


Constructor

Public constructor

Constructs a new instance of the ObjectValidator class

Parameters
NameDescription

config

{
  readonly [K in keyof Shape]: Validatable<Shape[K]>
}

shouldAllowUnknownProperties

boolean
References

Validatable


Properties

config

Public readonly property

Signature
readonly config: {
  readonly [K in keyof Shape]: Validatable<Shape[K]>
}
References

Validatable


Methods

allowUnknownProperties()

Public method

Signature
allowUnknownProperties(): ObjectValidator<Shape>
References

ObjectValidator


extend()

Public method

Extend an object validator by adding additional properties.

Example
const animalValidator = T.object({
  name: T.string,
})
const catValidator = animalValidator.extend({
  meowVolume: T.number,
})
Signature
extend<Extension extends Record<string, unknown>>(extension: {
  readonly [K in keyof Extension]: Validatable<Extension[K]>
}): ObjectValidator<Shape & Extension>
Parameters
NameDescription

extension

{
  readonly [K in keyof Extension]: Validatable<Extension[K]>
}
Returns
ObjectValidator<Shape & Extension>
References

Validatable, ObjectValidator


DictValidatorT