ValidationResult

Result generated by a schema validation

Description

The ValidationResult class provides a representation of the result generated by a schema validation.

Constructors

Creates a new instance of a validation ressult and sets its values. See ValidationResultType

public constructor(path: string = null, type: ValidationResultType = null, code: string = null, message: string = null, expected: any = null, actual: any = null)

  • path: string - a dot notation path of the validated element.
  • type: ValidationResultType = null - a type of the validation result: Information, Warning, or Error.
  • code: string - an error code.
  • message: string - a human readable message.
  • expected: any - an value expected by schema validation.
  • actual: any - an actual value found by schema validation.

Instance methods

getActual

Gets the actual value found by schema validation.

public getActual(): any

  • returns: any - the actual value.

getCode

Gets the error code.

public getCode(): string

  • returns: string - the error code

getExpected

Gets the value expected by schema validation.

public getExpected(): any

  • returns: any - the expected value.

getMessage

Gets the human readable message.

public getMessage(): string

  • returns: string - the result message.

getPath

Gets dot notation path of the validated element.

public getPath(): string

  • returns: string - the path of the validated element.

getType

Gets dot notation path of the validated element.

public getType(): ValidationResultType

toJSON

Returns the validation result in JSON format.

public toJSON(): object