ValidationResult

Result generated by a schema validation

Description

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

Constructors

NewValidationResult

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

NewValidationResult(path string, typ ValidationResultType, code string, message string, expected any, actual any) *ValidationResult

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

Methods

Actual

Gets the actual value found by a schema validation.

(c *ValidationResult) Actual() any

  • returns: any - actual value.

Code

Gets the error code.

(c *ValidationResult) Code() string

  • returns: string - error code

Expected

Gets the value expected by a schema validation.

(c *ValidationResult) Expected() any

  • returns: any - expected value.

Message

Gets the human readable message.

(c *ValidationResult) Message() string

  • returns: string - result message.

Path

Gets the dot notation path of the validated element.

(c *ValidationResult) Path() string

  • returns: string - path of the validated element.

getType

Gets dot notation path of the validated element.

(c *ValidationResult) Type() ValidationResultType