Interface SchemaFunctions<ValueT>

interface SchemaFunctions {
    allowNull: (() => Schema<null | ValueT>);
    deserialize: Deserializer<ValueT>;
    deserializeAsync: AsyncDeserializer<ValueT>;
    not: (<ExcludeT>(notSchema, options?) => Schema<Exclude<ValueT, ExcludeT>>);
    optional: (() => Schema<undefined | ValueT>);
    serialize: Serializer<ValueT>;
    serializeAsync: AsyncSerializer<ValueT>;
    setDescription: ((description?) => SchemaFunctions<ValueT>);
    setExample: ((example?) => SchemaFunctions<ValueT>);
    setPreferredValidationMode: ((validationMode) => SchemaFunctions<ValueT>);
    toString: (() => string);
    validate: Validator;
    validateAsync: AsyncValidator;
}

Type Parameters

  • ValueT

Properties

allowNull: (() => Schema<null | ValueT>)

Type declaration

    • (): Schema<null | ValueT>
    • Returns a new schema that requires that either this schema is satisfied or that the value is null.

      Returns Schema<null | ValueT>

deserialize: Deserializer<ValueT>

Synchronously deserialize (and validate) a value

deserializeAsync: AsyncDeserializer<ValueT>

Asynchronously deserialize (and validate) a value

not: (<ExcludeT>(notSchema, options?) => Schema<Exclude<ValueT, ExcludeT>>)

Type declaration

    • <ExcludeT>(notSchema, options?): Schema<Exclude<ValueT, ExcludeT>>
    • Returns a new schema that requires that this schema is satisfied but that the specified schema cannot be satisfied.

      Type Parameters

      • ExcludeT

      Parameters

      • notSchema: Schema<ExcludeT>
      • Optional options: {
            expectedTypeName?: string;
        }
        • Optional expectedTypeName?: string

      Returns Schema<Exclude<ValueT, ExcludeT>>

optional: (() => Schema<undefined | ValueT>)

Type declaration

    • (): Schema<undefined | ValueT>
    • Returns a new schema that requires that either this schema is satisfied or that the value is undefined.

      Returns Schema<undefined | ValueT>

serialize: Serializer<ValueT>

Synchronously serialize (and validate) a value

serializeAsync: AsyncSerializer<ValueT>

Asynchronously serialize (and validate) a value

setDescription: ((description?) => SchemaFunctions<ValueT>)

Type declaration

    • (description?): SchemaFunctions<ValueT>
    • Sets (replaces) the description metadata for this schema and returns the same schema

      Parameters

      • Optional description: string

      Returns SchemaFunctions<ValueT>

setExample: ((example?) => SchemaFunctions<ValueT>)

Type declaration

    • (example?): SchemaFunctions<ValueT>
    • Sets (replaces) the example metadata for this schema and returns the same schema

      Parameters

      • Optional example: string

      Returns SchemaFunctions<ValueT>

setPreferredValidationMode: ((validationMode) => SchemaFunctions<ValueT>)

Type declaration

    • (validationMode): SchemaFunctions<ValueT>
    • Sets (replaces) the preferred validation mode for this schema and returns the same schema.

      The lesser level of the preferred validation mode, which will be applied recursively depending on the depth parameter / unless further re-specified, and the specified validation mode, will be used, where the order is none < soft < hard.

      Parameters

      • validationMode: SchemaPreferredValidationMode

        The preferred validation mode for this schema Special Values:

        • "initial" - use the initially specified validation mode for the current operation (ex. the validation field of the options parameter to deserialize).
        • "inherit" - use the closet applicable mode from an ancestor schema level.

      Returns SchemaFunctions<ValueT>

toString: (() => string)

Type declaration

    • (): string
    • Makes a string representation of this schema, mostly for debugging

      Returns string

validate: Validator

Synchronously validate a value

validateAsync: AsyncValidator

Asynchronously validate a value

Generated using TypeDoc