schema-utils

  • Version 4.8.5
  • Published
  • 135 kB
  • 4 dependencies
  • MIT license

Install

npm i schema-utils
yarn add schema-utils
pnpm add schema-utils

Overview

webpack Validation Utils

Index

Functions

function disableValidation

disableValidation: () => void;
  • Returns

    {void}

function enableValidation

enableValidation: () => void;
  • Returns

    {void}

function needValidate

needValidate: () => boolean;
  • Returns

    {boolean} true when need validate, otherwise false

function precompile

precompile: (
schema: import('./validate').Schema,
options?: import('./precompile').PrecompileOptions | undefined
) => ReturnType<typeof import('./precompile').default>;
  • Parameter args

    arguments

    Returns

    {ReturnType<typeof import("./precompile").default>} source of the module

function validate

validate: (
schema: Schema,
options: object[] | object,
configuration?: ValidationErrorConfiguration | undefined,
check?: PrecompiledCheck | undefined
) => void;
  • Parameter schema

    schema

    Parameter options

    options

    Parameter configuration

    configuration

    Parameter check

    precompiled check of the schema, so a valid value never compiles the schema

    Returns

    {void}

Classes

class ValidationError

class ValidationError extends Error {}

    constructor

    constructor(
    errors: any[],
    schema: any,
    configuration?: ValidationErrorConfiguration
    );
    • Parameter errors

      array of error objects

      Parameter schema

      schema

      Parameter configuration

      configuration

    property baseDataPath

    baseDataPath: string;
    • {string}

    property errors

    errors: any[];
    • {SchemaUtilErrorObject[]}

    property headerName

    headerName: string;
    • {string}

    property postFormatter

    postFormatter: PostFormatter;
    • {PostFormatter | null}

    property schema

    schema: any;
    • {Schema}

    method formatSchema

    formatSchema: (
    schema: Schema,
    logic?: boolean,
    prevSchemas?: object[]
    ) => string;
    • Parameter schema

      schema

      Parameter logic

      logic

      Parameter prevSchemas

      prev schemas

      Returns

      {string} formatted schema

    method formatValidationError

    formatValidationError: (error: SchemaUtilErrorObject) => string;
    • Parameter error

      error object

      Returns

      {string} formatted error object

    method formatValidationErrors

    formatValidationErrors: (errors: SchemaUtilErrorObject[]) => string;
    • Parameter errors

      errors

      Returns

      {string} formatted errors

    method getSchemaPart

    getSchemaPart: (path: string) => Schema;
    • Parameter path

      path

      Returns

      {Schema} schema

    method getSchemaPartDescription

    getSchemaPartDescription: (schemaPart?: Schema | undefined) => string;
    • Parameter schemaPart

      schema part

      Returns

      {string} schema part description

    method getSchemaPartText

    getSchemaPartText: (
    schemaPart?: Schema | undefined,
    additionalPath?: (boolean | string[]) | undefined,
    needDot?: boolean | undefined,
    logic?: boolean | undefined
    ) => string;
    • Parameter schemaPart

      schema part

      Parameter additionalPath

      additional path

      Parameter needDot

      true when need dot

      Parameter logic

      logic

      Returns

      {string} schema part text

    Type Aliases

    type ExtendedSchema

    type ExtendedSchema = import('./validate').ExtendedSchema;

      type JSONSchema4

      type JSONSchema4 = import('./validate').JSONSchema4;

        type JSONSchema6

        type JSONSchema6 = import('./validate').JSONSchema6;

          type JSONSchema7

          type JSONSchema7 = import('./validate').JSONSchema7;

            type PrecompiledCheck

            type PrecompiledCheck = import('./validate').PrecompiledCheck;

              type PrecompileOptions

              type PrecompileOptions = import('./precompile').PrecompileOptions;

                type Schema

                type Schema = import('./validate').Schema;

                  type ValidationErrorConfiguration

                  type ValidationErrorConfiguration =
                  import('./validate').ValidationErrorConfiguration;

                    Package Files (3)

                    Dependencies (4)

                    Dev Dependencies (18)

                    Peer Dependencies (1)

                    Badge

                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/schema-utils.

                    • Markdown
                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/schema-utils)
                    • HTML
                      <a href="https://www.jsdocs.io/package/schema-utils"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>