Options
All
  • Public
  • Public/Protected
  • All
Menu

The ValidationContext instance for a certain annotation and property combination is created when the run time loads the class that has been annotated.

Example

We have a name property decorated with the the IsAlpha annotation like this:

public class Person {
@IsAlpha()
public name:string;
}

When that annotation runs it creates a ValidationContext instance with the signature IsAlpha_Person_name that is specific to the Person class and the name property.

The ValidationContext instance is initialized with the parameters necessary to perform an IsAlpha validation on the name property of a Person instance.

Hierarchy

  • ValidationContext

Index

Constructors

constructor

Properties

decorator

decorator: string

Validation Decorator Function Name.

errorMessage

errorMessage: ErrorMessageType

The default error message function

object

object: any

An instance of the class that has been decorated.

propertyName

propertyName: string

Property of the object to be validated.

Optional skipErrorGeneration

skipErrorGeneration?: boolean

Whether validation should continue in the event of an error. For example is a value is undefined, then there's little point applying the other validators.

stop

stop: boolean

Whether validation should continue in the event of an error.

For example is a value is undefined, then there's little point in applying the other validators.

target

target: Function

Constructor function of the instance being validated.

Optional validateArray

Function that performs the validation of properties containing arrays.

validateValue

Function that performs the validation of single values.

Optional validationOptions

validationOptions?: ValidationOptions

Validation options.

validationParameters

validationParameters: any[]

Validation constraint parameters for the validation.

Optional validationTypeOptions

validationTypeOptions?: any

Validation options specific to the type of validation being performd.

Methods

getSignature

  • getSignature(): string
  • The signature for the decorator, class, and class property combination.

    Below is a getSignature example of what would be produced when the ValidationContext were formed from the IfValid annotation applied to the purchasePrice property of a SalesOrder instance.

    Example

    IfValid_SalesOrder_purchasePrice
    

    Returns string

Generated using TypeDoc