vue-types

  • Version 7.0.0
  • Published
  • 221 kB
  • No dependencies
  • MIT license

Install

npm i vue-types
yarn add vue-types
pnpm add vue-types

Overview

Prop types utility for Vue

Index

Variables

variable config

const config: VueTypesConfig;

    variable VueTypes_base

    const VueTypes_base: {
    new (): {};
    defaults: Partial<VueTypesDefaults>;
    sensibleDefaults: boolean | Partial<VueTypesDefaults>;
    config: VueTypesConfig;
    readonly any: VueTypeValidableDef<any, ValidatorFunction<any>>;
    readonly func: VueTypeValidableDef<
    (...args: any[]) => any,
    ValidatorFunction<(...args: any[]) => any>
    > & { default: (...args: any[]) => any };
    readonly bool: VueTypeValidableDef<boolean, ValidatorFunction<boolean>>;
    readonly string: VueTypeValidableDef<string, ValidatorFunction<string>> & {
    default: string;
    };
    readonly number: VueTypeValidableDef<number, ValidatorFunction<number>> & {
    default: number;
    };
    readonly array: VueTypeValidableDef<unknown[], ValidatorFunction<unknown[]>> & {
    default: () => unknown[];
    };
    readonly object: VueTypeValidableDef<
    Record<string, any>,
    ValidatorFunction<Record<string, any>>
    > & { default: () => Record<string, any> };
    readonly integer: VueTypeDef<number> & { default: number };
    readonly symbol: VueTypeDef<symbol>;
    readonly nullable: PropOptions<null, null>;
    readonly custom: typeof custom;
    readonly oneOf: typeof oneOf;
    readonly instanceOf: typeof instanceOf;
    readonly oneOfType: typeof oneOfType;
    readonly arrayOf: typeof arrayOf;
    readonly objectOf: typeof objectOf;
    readonly shape: typeof shape;
    extend(..._args: any[]): void;
    utils: {
    validate(value: unknown, type: unknown): boolean;
    toType: typeof utilsToType;
    };
    };

      Functions

      function any

      any: <T = any>() => VueTypeValidableDef<T, ValidatorFunction<T>>;

        function array

        array: <T>() => VueTypeValidableDef<T[], ValidatorFunction<T[]>>;

          function arrayOf

          arrayOf: <T extends unknown>(type: T) => VueTypeDef<InferType<T>[]>;

            function bool

            bool: () => VueTypeValidableDef<boolean, ValidatorFunction<boolean>>;

              function createTypes

              createTypes: (defs?: Partial<VueTypesDefaults>) => {
              new (): {};
              defaults: Partial<VueTypesDefaults>;
              sensibleDefaults: boolean | Partial<VueTypesDefaults>;
              config: VueTypesConfig;
              readonly any: VueTypeValidableDef<any, ValidatorFunction<any>>;
              readonly func: VueTypeValidableDef<
              (...args: any[]) => any,
              ValidatorFunction<(...args: any[]) => any>
              > & { default: (...args: any[]) => any };
              readonly bool: VueTypeValidableDef<boolean, ValidatorFunction<boolean>>;
              readonly string: VueTypeValidableDef<string, ValidatorFunction<string>> & {
              default: string;
              };
              readonly number: VueTypeValidableDef<number, ValidatorFunction<number>> & {
              default: number;
              };
              readonly array: VueTypeValidableDef<unknown[], ValidatorFunction<unknown[]>> & {
              default: () => unknown[];
              };
              readonly object: VueTypeValidableDef<
              Record<string, any>,
              ValidatorFunction<Record<string, any>>
              > & { default: () => Record<string, any> };
              readonly integer: VueTypeDef<number> & { default: number };
              readonly symbol: VueTypeDef<symbol>;
              readonly nullable: PropOptions<null, null>;
              readonly custom: typeof custom;
              readonly oneOf: typeof oneOf;
              readonly instanceOf: typeof instanceOf;
              readonly oneOfType: typeof oneOfType;
              readonly arrayOf: typeof arrayOf;
              readonly objectOf: typeof objectOf;
              readonly shape: typeof shape;
              extend(..._args: any[]): void;
              utils: {
              validate(value: unknown, type: unknown): boolean;
              toType: typeof utilsToType;
              };
              };

                function custom

                custom: <T>(
                validatorFn: ValidatorFunction<T>,
                warnMsg?: string
                ) => VueTypeDef<T>;

                  function fromType

                  fromType: {
                  <T extends VueTypeDef<any>>(name: string, source: T): T;
                  <T extends VueTypeDef<any>, V extends PropOptions<InferType<T>, InferType<T>>>(
                  name: string,
                  source: T,
                  props: V
                  ): Omit<T, keyof V> & V;
                  };
                  • Return a new VueTypes type using another type as base.

                    Properties in the props object will overwrite those defined in the source one expect for the validator function. In that case both functions will be executed in series.

                    Parameter name

                    Name of the new type

                    Parameter source

                    Source type

                    Parameter props

                    Custom type properties

                  function func

                  func: <T extends (...args: any[]) => any>() => VueTypeValidableDef<
                  T,
                  ValidatorFunction<T>
                  >;

                    function instanceOf

                    instanceOf: <C extends Constructor>(
                    instanceConstructor: C
                    ) => VueTypeDef<InstanceType<C>>;

                      function integer

                      integer: <T extends number = number>() => VueTypeDef<T>;

                        function nullable

                        nullable: () => PropOptions<null>;

                          function number

                          number: <T extends number = number>() => VueTypeValidableDef<
                          T,
                          ValidatorFunction<T>
                          >;

                            function object

                            object: <T extends Record<string, any>>() => VueTypeValidableDef<
                            T,
                            ValidatorFunction<T>
                            >;

                              function objectOf

                              objectOf: <T extends unknown>(
                              type: T
                              ) => VueTypeDef<Record<string, InferType<T>>>;

                                function oneOf

                                oneOf: <D, T extends readonly D[] = readonly D[]>(
                                arr: T
                                ) => VueTypeDef<T[number]>;

                                  function oneOfType

                                  oneOfType: <D extends InferType<U>, U extends unknown = any>(
                                  arr: U[]
                                  ) => VueTypeDef<D>;

                                    function shape

                                    shape: <T extends object>(obj: { [K in keyof T]: any }) => VueTypeShape<T>;

                                      function string

                                      string: <T extends string = string>() => VueTypeValidableDef<
                                      T,
                                      ValidatorFunction<T>
                                      >;

                                        function symbol

                                        symbol: () => VueTypeDef<symbol>;

                                          function toType

                                          toType: <T = any>(name: string, obj: PropOptions<T>) => VueTypeDef<T>;
                                          • Adds isRequired and def modifiers to an object

                                            Parameter name

                                            Type internal name

                                            Parameter obj

                                            Object to enhance

                                          function toValidableType

                                          toValidableType: <T = any>(
                                          name: string,
                                          obj: PropOptions<T>
                                          ) => VueTypeValidableDef<T>;
                                          • Like toType but also adds the validate() method to the type object

                                            Parameter name

                                            Type internal name

                                            Parameter obj

                                            Object to enhance

                                          function utilsToType

                                          utilsToType: {
                                          <T = unknown>(
                                          name: string,
                                          obj: PropOptions<T>,
                                          validable: true
                                          ): VueTypeValidableDef<T>;
                                          <T = unknown>(
                                          name: string,
                                          obj: PropOptions<T, T>,
                                          validable?: false
                                          ): VueTypeDef<T>;
                                          };

                                            function validateType

                                            validateType: (
                                            type: unknown,
                                            value: unknown,
                                            silent?: boolean
                                            ) => string | boolean;
                                            • Validates a given value against a prop type object.

                                              If silent is false (default) will return a boolean. If it is set to true it will return true on success or a string error message on failure

                                              Parameter type

                                              Type to use for validation. Either a type object or a constructor

                                              Parameter value

                                              Value to check

                                              Parameter silent

                                              Silence warnings

                                            Classes

                                            class VueTypes

                                            class VueTypes extends VueTypes_base {}

                                              Interfaces

                                              interface VueTypeLooseShape

                                              interface VueTypeLooseShape<T>
                                              extends VueTypeBaseDef<
                                              T,
                                              DefaultFactory<Partial<T & Record<string, any>>>,
                                              () => Partial<T> & Record<string, any>
                                              > {}

                                                property loose

                                                readonly loose: VueTypeLooseShape<T>;

                                                  interface VueTypeShape

                                                  interface VueTypeShape<T>
                                                  extends VueTypeBaseDef<T, DefaultType<Partial<T>>, () => Partial<T>> {}

                                                    property loose

                                                    readonly loose: VueTypeLooseShape<T>;

                                                      interface VueTypeValidableDef

                                                      interface VueTypeValidableDef<T = unknown, V = ValidatorFunction<T>>
                                                      extends VueTypeBaseDef<T> {}

                                                        property validate

                                                        readonly validate: (fn: V) => this & { validator: V };

                                                          Type Aliases

                                                          type VueTypeDef

                                                          type VueTypeDef<T = unknown> = VueTypeBaseDef<T>;

                                                            type VueTypesInterface

                                                            type VueTypesInterface = ReturnType<typeof createTypes>;

                                                              Package Files (2)

                                                              Dependencies (0)

                                                              No dependencies.

                                                              Dev Dependencies (3)

                                                              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/vue-types.

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