Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @ovotech/json-schema

Index

Type aliases

Coercer<TSchema, TValue>: (schema: TSchema, value: TValue, options: CoercerOptions) => TValue

Type parameters

Type declaration

    • Parameters

      Returns TValue

FormatErrors: ((errors: Validation) => string[]) | boolean
InvalidCode: "not" | "enum" | "type" | "multipleOf" | "minimum" | "exclusiveMinimum" | "maximum" | "exclusiveMaximum" | "pattern" | "format" | "false" | "maxLength" | "minLength" | "contains" | "additionalProperties" | "unevaluatedProperties" | "unevaluatedItems" | "required" | "minProperties" | "maxProperties" | "dependencies" | "uniqueItems" | "minItems" | "maxItems" | "oneOf" | "anyOf"
Messages: Record<InvalidCode, (error: Invalid) => string>
PrimitiveType: "string" | "integer" | "number" | "boolean" | "array" | "object" | "null"
Result<T>: ResultSuccess<T> | ResultError

Type parameters

  • T

Schema: JsonSchema | boolean
Validator<TSchema, TValue>: (schema: TSchema, value: TValue, options: Options) => Validation

Type parameters

Type declaration

Variables

coercers: { json: Coercer<JsonSchema, unknown>[]; query: Coercer<JsonSchema, unknown>[] } = ...

Type declaration

empty: Validation = ...
messages: Messages = ...

Functions

  • Coerce a given value, using the provided json schema.

    • With type: 'json' This is used to convert json validated with json schema into javascript objects. Namely it converts all the strings with format date and date-time into Date objects
    • With type: 'query' To convert a value coming from a URL query string to the type you want it to be, for example '12' with type: 'integer' will be converted to 12 so the validation can succeed.

    Additionally, we assign default values where appropriate.

    Parameters

    Returns unknown

  • Parameters

    Returns Promise<unknown>

  • hasEvaluatedProperty(property: string, __namedParameters: Options | Validation): boolean

Generated using TypeDoc