Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ModelValidator

A specialized ObjectValidator (from bsy-validation) that's used to validate objects against Formn Entity metadata.

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

  • new ModelValidator(objectValidator?: ObjectValidator): ModelValidator
  • Initialize with an ObjectValidator instance. This class decorates ObjectValidator's validate method.

    Parameters

    • Default value objectValidator: ObjectValidator = new ObjectValidator()

    Returns ModelValidator

Properties

Protected objectValidator

objectValidator: ObjectValidator

Methods

getValidationMetadata

  • getValidationMetadata(Entity: object): ValidationMetadata[]
  • Generate validation metadata (see bsy-validation) for the Entity.

    Parameters

    • Entity: object

    Returns ValidationMetadata[]

validate

  • validate(obj: object, Entity: object): Promise<void>
  • Verify that each property of obj meets the requirements defined by Column and Relationship decoration, such as data type, maximum length, and nullability. If valid, then check any user-defined validation, such as email and phone number validation. (Reference the bsy-validation package, as the ObjectValidator class is used for validation.)

    Parameters

    • obj: object

      The object to validate against class Entity.

    • Entity: object

      A class that has properties decorated with @Validate. This is the schema against which obj will be validated.

    Returns Promise<void>

Generated using TypeDoc