Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yup

Package Overview
Dependencies
Maintainers
1
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yup - npm Package Compare versions

Comparing version 1.0.0-alpha.2 to 1.0.0-alpha.3

es/util/objectTypes.d.ts

55

CHANGELOG.md

@@ -0,1 +1,56 @@

## [0.32.11](https://github.com/jquense/yup/compare/v0.32.10...v0.32.11) (2021-10-12)
### Bug Fixes
* dep ranges ([2015c0f](https://github.com/jquense/yup/commit/2015c0f717065360076d5c460a139a2fff410166))
## [0.32.10](https://github.com/jquense/yup/compare/v0.32.9...v0.32.10) (2021-10-11)
### Bug Fixes
* carry over excluded edges when concating objects ([5334349](https://github.com/jquense/yup/commit/53343491f0624120812182a70919a2fc3ebe11f5)), closes [#1423](https://github.com/jquense/yup/issues/1423)
* fix the typo for the array length validation ([#1287](https://github.com/jquense/yup/issues/1287)) ([4c17508](https://github.com/jquense/yup/commit/4c175086ce8e53df529bbdff6f215929a5a39167))
* missing transforms on concat ([f3056f2](https://github.com/jquense/yup/commit/f3056f2cbade92eaf0427848f43df97eae010555)), closes [#1260](https://github.com/jquense/yup/issues/1260)
* oneOf, notOneOf swallowing multiple errors ([#1434](https://github.com/jquense/yup/issues/1434)) ([7842afb](https://github.com/jquense/yup/commit/7842afbaca0a44fc2fea72b44a90c2000ca2b8f0))
* prevent unhandled Promise rejection when returning rejected Promise inside test function ([#1327](https://github.com/jquense/yup/issues/1327)) ([5eda549](https://github.com/jquense/yup/commit/5eda549dfce95be225b0eb6dbe3cbe7bcd5d3347))
* SchemaOf<>'s treatment of Date objects. ([#1305](https://github.com/jquense/yup/issues/1305)) ([91ace1e](https://github.com/jquense/yup/commit/91ace1e8be3fc23c775ec8117c47b406bf29da4a)), closes [#1243](https://github.com/jquense/yup/issues/1243) [#1302](https://github.com/jquense/yup/issues/1302)
* update lodash/lodash-es to fix CVEs flagged in 4.17.20 ([#1334](https://github.com/jquense/yup/issues/1334)) ([70d0b67](https://github.com/jquense/yup/commit/70d0b67e172f695168c5d00bc9856f2f775e0957))
* **utils:** use named functions for default exports ([#1329](https://github.com/jquense/yup/issues/1329)) ([acbb8b4](https://github.com/jquense/yup/commit/acbb8b4f3c24ceaf65eab09abaf8e086a9f11a73))
### Features
* add resolved to params ([#1437](https://github.com/jquense/yup/issues/1437)) ([03584f6](https://github.com/jquense/yup/commit/03584f6758ff43409113c41f58fd41e065aa18a3))
* add types to setLocale ([#1427](https://github.com/jquense/yup/issues/1427)) ([7576cd8](https://github.com/jquense/yup/commit/7576cd836ce9b660c054f9117795dbd9be12f747)), closes [#1321](https://github.com/jquense/yup/issues/1321)
* allows custom types to be passed to avoid cast to ObjectSchema ([#1358](https://github.com/jquense/yup/issues/1358)) ([94cfd11](https://github.com/jquense/yup/commit/94cfd11b3f23e10f731efac05c5525829d10ded1))
## [0.32.9](https://github.com/jquense/yup/compare/v0.32.6...v0.32.9) (2021-02-17)
### Bug Fixes
* **types:** Array required() and defined() will no longer return any ([#1256](https://github.com/jquense/yup/issues/1256)) ([52e5876](https://github.com/jquense/yup/commit/52e5876))
* export MixedSchema to fix ts with --declarations ([#1204](https://github.com/jquense/yup/issues/1204)) ([67c96ae](https://github.com/jquense/yup/commit/67c96ae))
* **types:** add generic to Reference.create() ([#1208](https://github.com/jquense/yup/issues/1208)) ([be3d1b4](https://github.com/jquense/yup/commit/be3d1b4))
* **types:** reach and getIn make last 2 arguments optional ([#1194](https://github.com/jquense/yup/issues/1194)) ([5cf2c48](https://github.com/jquense/yup/commit/5cf2c48))
* do not initialize spec values with undefined ([#1177](https://github.com/jquense/yup/issues/1177)) ([e8e5b46](https://github.com/jquense/yup/commit/e8e5b46)), closes [jquense/yup#1160](https://github.com/jquense/yup/issues/1160) [jquense/yup#1160](https://github.com/jquense/yup/issues/1160)
* **types:** meta() return type ([e41040a](https://github.com/jquense/yup/commit/e41040a))
* array handling in SchemaOf type ([#1169](https://github.com/jquense/yup/issues/1169)) ([e785e1a](https://github.com/jquense/yup/commit/e785e1a))
* **types:** make StringSchema.matches options optional ([#1166](https://github.com/jquense/yup/issues/1166)) ([b53e5f2](https://github.com/jquense/yup/commit/b53e5f2))
* **types:** SchemaOf doesn't produce a union of base schema ([2d71f32](https://github.com/jquense/yup/commit/2d71f32))
## [0.32.6](https://github.com/jquense/yup/compare/v0.32.5...v0.32.6) (2020-12-08)

@@ -2,0 +57,0 @@

45

es/array.d.ts
import type { AnyObject, InternalOptions, Callback, Message, Maybe } from './types';
import type Reference from './Reference';
import { Asserts, Config, Defined, NotNull, SetFlag, Thunk, ToggleDefault } from './util/types';
import BaseSchema, { AnySchema, SchemaInnerTypeDescription, SchemaSpec } from './schema';
import Lazy from './Lazy';
import { Defined, Flags, NotNull, SetFlag, Thunk, ToggleDefault, ISchema, UnsetFlag } from './util/types';
import BaseSchema, { SchemaInnerTypeDescription, SchemaSpec } from './schema';
import { ResolveOptions } from './Condition';
export declare type RejectorFn = (value: any, index: number, array: any[]) => boolean;
export declare function create<C extends AnyObject = AnyObject, T extends AnySchema | Lazy<any, any> = AnySchema>(type?: T): ArraySchema<T, Config<C, "">, Asserts<T>[] | undefined>;
export declare function create<C extends AnyObject = AnyObject, T = any>(type?: ISchema<T, C>): ArraySchema<T, C, undefined, "", T[] | undefined>;
export declare namespace create {
var prototype: ArraySchema<any, any, any>;
var prototype: ArraySchema<any, any, any, any, any>;
}
export default class ArraySchema<T extends AnySchema | Lazy<any, any>, C extends Config<any, any> = Config, TIn extends Maybe<Asserts<T>[]> = Asserts<T>[] | undefined> extends BaseSchema<TIn, C> {
innerType?: T;
constructor(type?: T);
export default class ArraySchema<T, TContext, TDefault = undefined, TFlags extends Flags = '', TIn extends any[] | null | undefined = T[] | undefined> extends BaseSchema<TIn, TContext, TDefault, TFlags> {
innerType?: ISchema<T, TContext>;
constructor(type?: ISchema<T, TContext>);
protected _typeCheck(v: any): v is NonNullable<TIn>;
private get _subType();
protected _cast(_value: any, _opts: InternalOptions<C>): any;
protected _validate(_value: any, options: InternalOptions<C> | undefined, callback: Callback): void;
protected _cast(_value: any, _opts: InternalOptions<TContext>): any;
protected _validate(_value: any, options: InternalOptions<TContext> | undefined, callback: Callback): void;
clone(spec?: SchemaSpec<any>): this;
concat<TOther extends ArraySchema<any, any, any>>(schema: TOther): TOther;
concat(schema: any): any;
of<TInner extends AnySchema>(schema: TInner): ArraySchema<TInner>;
of<U>(schema: ISchema<U, TContext>): ArraySchema<U, TContext, TFlags>;
length(length: number | Reference<number>, message?: Message<{

@@ -32,14 +31,18 @@ length: number;

}>): this;
ensure(): ArraySchema<T, SetFlag<C, 'd'>, NonNullable<TIn>>;
ensure(): ArraySchema<T, TContext, TIn, ToggleDefault<TFlags, TIn>, TIn>;
compact(rejector?: RejectorFn): this;
describe(options?: ResolveOptions<C['context']>): SchemaInnerTypeDescription;
describe(options?: ResolveOptions<TContext>): SchemaInnerTypeDescription;
}
export default interface ArraySchema<T extends AnySchema | Lazy<any, any>, C extends Config<any, any> = Config, TIn extends Maybe<Asserts<T>[]> = Asserts<T>[] | undefined> extends BaseSchema<TIn, C> {
default<D extends Maybe<TIn>>(def: Thunk<D>): ArraySchema<T, ToggleDefault<C, D>, TIn>;
defined(msg?: Message): ArraySchema<T, C, Defined<TIn>>;
optional(): ArraySchema<T, C, TIn | undefined>;
required(msg?: Message): ArraySchema<T, C, NonNullable<TIn>>;
notRequired(): ArraySchema<T, C, Maybe<TIn>>;
nullable(isNullable?: true): ArraySchema<T, C, TIn | null>;
nullable(isNullable: false): ArraySchema<T, C, NotNull<TIn>>;
export default interface ArraySchema<T, TContext, TDefault = undefined, TFlags extends Flags = '', TIn extends any[] | null | undefined = T[] | undefined> extends BaseSchema<TIn, TContext, TDefault, TFlags> {
default<D extends Maybe<TIn>>(def: Thunk<D>): ArraySchema<T, TContext, D, ToggleDefault<TFlags, D>, TIn>;
concat<IT, IC, ID, IF extends Flags, IIn extends Maybe<IT[]>>(schema: ArraySchema<IT, IC, ID, IF, IIn>): ArraySchema<NonNullable<T> | IT, TContext & IC, Extract<IF, 'd'> extends never ? TDefault : ID, TFlags | IF, IIn>;
concat(schema: this): this;
defined(msg?: Message): ArraySchema<T, TContext, TDefault, TFlags, Defined<TIn>>;
optional(): ArraySchema<T, TContext, TDefault, TFlags, TIn | undefined>;
required(msg?: Message): ArraySchema<T, TContext, TDefault, TFlags, NonNullable<TIn>>;
notRequired(): ArraySchema<T, TContext, TDefault, TFlags, Maybe<TIn>>;
nullable(msg?: Message): ArraySchema<T, TContext, TDefault, TFlags, TIn | null>;
nonNullable(): ArraySchema<T, TContext, TDefault, TFlags, NotNull<TIn>>;
strip(enabled: false): ArraySchema<T, TContext, TDefault, UnsetFlag<TFlags, 's'>>;
strip(enabled?: true): ArraySchema<T, TContext, TDefault, SetFlag<TFlags, 's'>>;
}

@@ -20,2 +20,3 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

this.innerType = void 0;
this.innerType = type;

@@ -189,4 +190,5 @@ this.withMutation(() => {

});
}
} // ArraySchema<T, TContext, T[], SetFlag<TFlags, 'd'>, NonNullable<TIn>>
ensure() {

@@ -227,4 +229,2 @@ return this.default(() => []).transform((val, original) => {

}
create.prototype = ArraySchema.prototype; //
// Interfaces
//
create.prototype = ArraySchema.prototype;
import BaseSchema from './schema';
import type { AnyObject, Maybe, Message } from './types';
import type { Config, Defined, NotNull, Thunk, ToggleDefault } from './util/types';
import type { Defined, Flags, NotNull, SetFlag, Thunk, ToggleDefault } from './util/types';
export declare function create(): BooleanSchema;
export declare function create<T extends boolean, TContext = AnyObject>(): BooleanSchema<T | undefined, TContext>;
export declare namespace create {
var prototype: BooleanSchema<any, any>;
var prototype: BooleanSchema<any, any, any, any>;
}
export declare function create<T extends boolean, TContext = AnyObject>(): BooleanSchema<T | undefined, Config<TContext>>;
export declare namespace create {
var prototype: BooleanSchema<any, any>;
}
export default class BooleanSchema<TType extends Maybe<boolean> = boolean | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
export default class BooleanSchema<TType extends Maybe<boolean> = boolean | undefined, TContext = AnyObject, TDefault = undefined, TFlags extends Flags = ''> extends BaseSchema<TType, TContext, TDefault, TFlags> {
constructor();
protected _typeCheck(v: any): v is NonNullable<TType>;
isTrue(message?: string | Record<string | number | symbol, unknown> | ((params: any) => unknown) | undefined): BooleanSchema<TType | true, TConfig>;
isFalse(message?: string | Record<string | number | symbol, unknown> | ((params: any) => unknown) | undefined): BooleanSchema<TType | false, TConfig>;
isTrue(message?: Message<any> | undefined): BooleanSchema<TType | true, TContext, TFlags>;
isFalse(message?: Message<any> | undefined): BooleanSchema<TType | false, TContext, TFlags>;
default<D extends Maybe<TType>>(def: Thunk<D>): BooleanSchema<TType, TContext, D, ToggleDefault<TFlags, D>>;
defined(msg?: Message): BooleanSchema<Defined<TType>, TContext, TDefault, TFlags>;
optional(): BooleanSchema<TType | undefined, TContext, TDefault, TFlags>;
required(msg?: Message): BooleanSchema<NonNullable<TType>, TContext, TDefault, TFlags>;
notRequired(): BooleanSchema<Maybe<TType>, TContext, TDefault, TFlags>;
nullable(): BooleanSchema<TType | null, TContext, TDefault, TFlags>;
nonNullable(msg?: Message): BooleanSchema<NotNull<TType>, TContext, TDefault, TFlags>;
strip(): BooleanSchema<TType, TContext, TDefault, SetFlag<TFlags, 's'>>;
}
export default interface BooleanSchema<TType extends Maybe<boolean>, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
default<D extends Maybe<TType>>(def: Thunk<D>): BooleanSchema<TType, ToggleDefault<TConfig, D>>;
concat<TOther extends BooleanSchema<any, any>>(schema: TOther): TOther;
defined(msg?: Message): BooleanSchema<Defined<TType>, TConfig>;
optional(): BooleanSchema<TType | undefined, TConfig>;
required(msg?: Message): BooleanSchema<NonNullable<TType>, TConfig>;
notRequired(): BooleanSchema<Maybe<TType>, TConfig>;
nullable(msg?: Message): BooleanSchema<TType | null, TConfig>;
nonNullable(): BooleanSchema<NotNull<TType>, TConfig>;
}

@@ -61,3 +61,36 @@ import BaseSchema from './schema';

default(def) {
return super.default(def);
} // concat<TOther extends BooleanSchema<any, any>>(schema: TOther): TOther;
defined(msg) {
return super.defined(msg);
}
optional() {
return super.defined();
}
required(msg) {
return super.required(msg);
}
notRequired() {
return super.notRequired();
}
nullable() {
return super.nullable();
}
nonNullable(msg) {
return super.nonNullable(msg);
}
strip() {
return super.strip();
}
}
create.prototype = BooleanSchema.prototype;
import Reference from './Reference';
import { SchemaLike } from './types';
export interface ConditionBuilder<T extends SchemaLike> {
(this: T, value: any, schema: T): SchemaLike;
(v1: any, v2: any, schema: T): SchemaLike;
(v1: any, v2: any, v3: any, schema: T): SchemaLike;
(v1: any, v2: any, v3: any, v4: any, schema: T): SchemaLike;
import type { ISchema } from './util/types';
export interface ConditionBuilder<T extends ISchema<any, any>> {
(this: T, value: any, schema: T): ISchema<any, any> | void;
(v1: any, v2: any, schema: T): ISchema<any, any> | void;
(v1: any, v2: any, v3: any, schema: T): ISchema<any, any> | void;
(v1: any, v2: any, v3: any, v4: any, schema: T): ISchema<any, any> | void;
}
export declare type ConditionConfig<T extends SchemaLike> = {
export declare type ConditionConfig<T extends ISchema<any>> = {
is: any | ((...values: any[]) => boolean);
then?: SchemaLike | ((schema: T) => SchemaLike);
otherwise?: SchemaLike | ((schema: T) => SchemaLike);
then?: (schema: T) => ISchema<any>;
otherwise?: (schema: T) => ISchema<any>;
};
export declare type ConditionOptions<T extends SchemaLike> = ConditionBuilder<T> | ConditionConfig<T>;
export declare type ConditionOptions<T extends ISchema<any, any>> = ConditionBuilder<T> | ConditionConfig<T>;
export declare type ResolveOptions<TContext = any> = {

@@ -20,8 +20,8 @@ value?: any;

};
declare class Condition<T extends SchemaLike = SchemaLike> {
declare class Condition<T extends ISchema<any, any> = ISchema<any, any>> {
refs: Reference[];
fn: ConditionBuilder<T>;
constructor(refs: Reference[], options: ConditionOptions<T>);
resolve(base: T, options: ResolveOptions): any;
resolve(base: T, options: ResolveOptions): ISchema<any, import("./types").AnyObject, any, any> | T;
}
export default Condition;

@@ -5,2 +5,3 @@ import isSchema from './util/isSchema';

constructor(refs, options) {
this.fn = void 0;
this.refs = refs;

@@ -24,8 +25,9 @@ this.refs = refs;

this.fn = function (...args) {
let options = args.pop();
var _branch;
let _opts = args.pop();
let schema = args.pop();
let branch = check(...args) ? then : otherwise;
if (!branch) return undefined;
if (typeof branch === 'function') return branch(schema);
return schema.concat(branch.resolve(options));
return (_branch = branch == null ? void 0 : branch(schema)) != null ? _branch : schema;
};

@@ -35,3 +37,4 @@ }

resolve(base, options) {
let values = this.refs.map(ref => ref.getValue(options == null ? void 0 : options.value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context));
let values = this.refs.map(ref => // TODO: ? operator here?
ref.getValue(options == null ? void 0 : options.value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context));
let schema = this.fn.apply(base, values.concat(base, options));

@@ -38,0 +41,0 @@ if (schema === undefined || schema === base) return base;

import Ref from './Reference';
import type { AnyObject, Maybe, Message } from './types';
import type { Config, Defined, NotNull, Thunk, ToggleDefault } from './util/types';
import type { Defined, Flags, NotNull, SetFlag, Thunk, ToggleDefault, UnsetFlag } from './util/types';
import BaseSchema from './schema';
export declare function create(): DateSchema;
export declare function create<T extends Date, TContext = AnyObject>(): DateSchema<T | undefined, TContext>;
export declare namespace create {
var prototype: DateSchema<any, any>;
var prototype: DateSchema<any, any, any, any>;
var INVALID_DATE: Date;
}
export declare function create<T extends Date, TContext = AnyObject>(): DateSchema<T | undefined, Config<TContext>>;
export declare namespace create {
var prototype: DateSchema<any, any>;
var INVALID_DATE: Date;
}
export default class DateSchema<TType extends Maybe<Date> = Date | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
export default class DateSchema<TType extends Maybe<Date> = Date | undefined, TContext = AnyObject, TDefault = undefined, TFlags extends Flags = ''> extends BaseSchema<TType, TContext, TDefault, TFlags> {
static INVALID_DATE: Date;

@@ -27,11 +23,13 @@ constructor();

}
export default interface DateSchema<TType extends Maybe<Date>, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
default<D extends Maybe<TType>>(def: Thunk<D>): DateSchema<TType, ToggleDefault<TConfig, D>>;
export default interface DateSchema<TType extends Maybe<Date>, TContext = AnyObject, TDefault = undefined, TFlags extends Flags = ''> extends BaseSchema<TType, TContext, TDefault, TFlags> {
default<D extends Maybe<TType>>(def: Thunk<D>): DateSchema<TType, TContext, D, ToggleDefault<TFlags, D>>;
concat<TOther extends DateSchema<any, any>>(schema: TOther): TOther;
defined(msg?: Message): DateSchema<Defined<TType>, TConfig>;
optional(): DateSchema<TType | undefined, TConfig>;
required(msg?: Message): DateSchema<NonNullable<TType>, TConfig>;
notRequired(): DateSchema<Maybe<TType>, TConfig>;
nullable(msg?: Message): DateSchema<TType | null, TConfig>;
nonNullable(): DateSchema<NotNull<TType>, TConfig>;
defined(msg?: Message): DateSchema<Defined<TType>, TContext, TDefault, TFlags>;
optional(): DateSchema<TType | undefined, TContext, TDefault, TFlags>;
required(msg?: Message): DateSchema<NonNullable<TType>, TContext, TDefault, TFlags>;
notRequired(): DateSchema<Maybe<TType>, TContext, TDefault, TFlags>;
nullable(msg?: Message): DateSchema<TType | null, TContext, TDefault, TFlags>;
nonNullable(): DateSchema<NotNull<TType>, TContext, TDefault, TFlags>;
strip(enabled: false): DateSchema<TType, TContext, TDefault, UnsetFlag<TFlags, 's'>>;
strip(enabled?: true): DateSchema<TType, TContext, TDefault, SetFlag<TFlags, 's'>>;
}

@@ -1,2 +0,2 @@

import MixedSchema, { create as mixedCreate } from './mixed';
import Mixed, { create as mixedCreate, MixedSchema } from './mixed';
import BooleanSchema, { create as boolCreate } from './boolean';

@@ -15,13 +15,9 @@ import StringSchema, { create as stringCreate } from './string';

import BaseSchema, { AnySchema } from './schema';
import type { TypeOf, Asserts, Config } from './util/types';
import type { InferType } from './util/types';
declare function addMethod<T extends AnySchema>(schemaType: (...arg: any[]) => T, name: string, fn: (this: T, ...args: any[]) => T): void;
declare function addMethod<T extends new (...args: any) => AnySchema>(schemaType: T, name: string, fn: (this: InstanceType<T>, ...args: any[]) => InstanceType<T>): void;
declare type ObjectSchemaOf<T extends AnyObject> = ObjectSchema<{
[k in keyof T]-?: T[k] extends Array<infer E> ? ArraySchema<SchemaOf<E>> : T[k] extends AnyObject ? ObjectSchemaOf<T[k]> : BaseSchema<T[k], Config>;
}>;
declare type SchemaOf<T> = T extends Array<infer E> ? ArraySchema<SchemaOf<E>> : T extends AnyObject ? ObjectSchemaOf<T> : BaseSchema<T, Config>;
export declare type AnyObjectSchema = ObjectSchema<any, any, any>;
export type { SchemaOf, TypeOf, Asserts, Asserts as InferType, AnySchema };
export declare type AnyObjectSchema = ObjectSchema<any, any, any, any>;
export type { AnyObject, InferType, InferType as Asserts, AnySchema };
export { mixedCreate as mixed, boolCreate as bool, boolCreate as boolean, stringCreate as string, numberCreate as number, dateCreate as date, objectCreate as object, arrayCreate as array, refCreate as ref, lazyCreate as lazy, reach, isSchema, addMethod, setLocale, ValidationError, };
export { BaseSchema, MixedSchema, BooleanSchema, StringSchema, NumberSchema, DateSchema, ObjectSchema, ArraySchema, };
export { BaseSchema, Mixed as MixedSchema, MixedSchema as MixedSchemaClass, BooleanSchema, StringSchema, NumberSchema, DateSchema, ObjectSchema, ArraySchema, };
export type { CreateErrorOptions, TestContext, TestFunction, TestOptions, TestConfig, } from './util/createValidation';

@@ -1,2 +0,2 @@

import MixedSchema, { create as mixedCreate } from './mixed';
import Mixed, { create as mixedCreate, MixedSchema } from './mixed';
import BooleanSchema, { create as boolCreate } from './boolean';

@@ -24,2 +24,2 @@ import StringSchema, { create as stringCreate } from './string';

export { mixedCreate as mixed, boolCreate as bool, boolCreate as boolean, stringCreate as string, numberCreate as number, dateCreate as date, objectCreate as object, arrayCreate as array, refCreate as ref, lazyCreate as lazy, reach, isSchema, addMethod, setLocale, ValidationError };
export { BaseSchema, MixedSchema, BooleanSchema, StringSchema, NumberSchema, DateSchema, ObjectSchema, ArraySchema };
export { BaseSchema, Mixed as MixedSchema, MixedSchema as MixedSchemaClass, BooleanSchema, StringSchema, NumberSchema, DateSchema, ObjectSchema, ArraySchema };

@@ -1,34 +0,35 @@

import type { Callback, ValidateOptions } from './types';
import type { AnyObject, Callback, ValidateOptions } from './types';
import type { ResolveOptions } from './Condition';
import type { AnySchema, CastOptions, ConfigOf, SchemaFieldDescription, SchemaLazyDescription } from './schema';
import { Config, TypedSchema, TypeOf } from './util/types';
export declare type LazyBuilder<T extends AnySchema = any> = (value: any, options: ResolveOptions) => T;
export declare function create<T extends AnySchema>(builder: LazyBuilder<T>): Lazy<T, ConfigOf<T>>;
export declare type LazyReturnValue<T> = T extends Lazy<infer TSchema> ? TSchema : never;
export declare type LazyType<T> = LazyReturnValue<T> extends TypedSchema ? TypeOf<LazyReturnValue<T>> : never;
import type { CastOptions, SchemaFieldDescription, SchemaLazyDescription } from './schema';
import { Flags, ISchema } from './util/types';
import { BaseSchema } from '.';
export declare type LazyBuilder<T, TContext = AnyObject, TDefault = any, TFlags extends Flags = any> = (value: any, options: ResolveOptions) => ISchema<T, TContext, TFlags, TDefault>;
export declare function create<T, TContext = AnyObject, TFlags extends Flags = any, TDefault = any>(builder: LazyBuilder<T, TContext, TDefault, TFlags>): Lazy<T, TContext, TDefault, TFlags>;
export interface LazySpec {
meta: Record<string, unknown> | undefined;
}
declare class Lazy<T extends AnySchema, TConfig extends Config = ConfigOf<T>> implements TypedSchema {
declare class Lazy<T, TContext = AnyObject, TDefault = any, TFlags extends Flags = any> implements ISchema<T, TContext, TFlags, TDefault> {
private builder;
type: "lazy";
__isYupSchema__: boolean;
readonly __type: T['__type'];
readonly __outputType: T['__outputType'];
readonly __outputType: T;
readonly __context: TContext;
readonly __flags: TFlags;
readonly __default: TDefault;
spec: LazySpec;
constructor(builder: LazyBuilder<T>);
clone(): Lazy<T, TConfig>;
constructor(builder: LazyBuilder<T, TContext, TDefault, TFlags>);
clone(): Lazy<T, TContext, TDefault, TFlags>;
private _resolve;
resolve(options: ResolveOptions<TConfig['context']>): T;
cast(value: any, options?: CastOptions<TConfig['context']>): T['__type'];
validate(value: any, options?: ValidateOptions, maybeCb?: Callback): T['__outputType'];
validateSync(value: any, options?: ValidateOptions<TConfig['context']>): T['__outputType'];
validateAt(path: string, value: any, options?: ValidateOptions<TConfig['context']>): Promise<any>;
validateSyncAt(path: string, value: any, options?: ValidateOptions<TConfig['context']>): any;
isValid(value: any, options?: ValidateOptions<TConfig['context']>): Promise<boolean>;
isValidSync(value: any, options?: ValidateOptions<TConfig['context']>): boolean;
describe(options?: ResolveOptions<TConfig['context']>): SchemaLazyDescription | SchemaFieldDescription;
resolve(options: ResolveOptions<TContext>): BaseSchema<T, TContext, TDefault, TFlags>;
cast(value: any, options?: CastOptions<TContext>): T;
validate(value: any, options?: ValidateOptions, maybeCb?: Callback): Promise<T>;
validateSync(value: any, options?: ValidateOptions<TContext>): T;
validateAt(path: string, value: any, options?: ValidateOptions<TContext>): Promise<any>;
validateSyncAt(path: string, value: any, options?: ValidateOptions<TContext>): any;
isValid(value: any, options?: ValidateOptions<TContext>): Promise<boolean>;
isValidSync(value: any, options?: ValidateOptions<TContext>): boolean;
describe(options?: ResolveOptions<TContext>): SchemaLazyDescription | SchemaFieldDescription;
meta(): Record<string, unknown> | undefined;
meta(obj: Record<string, unknown>): Lazy<T, TConfig>;
meta(obj: Record<string, unknown>): Lazy<T, TContext, TDefault, TFlags>;
}
export default Lazy;

@@ -12,2 +12,3 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

this.__isYupSchema__ = true;
this.spec = void 0;

@@ -27,3 +28,3 @@ this._resolve = (value, options = {}) => {

clone() {
const next = new Lazy(this.builder);
const next = create(this.builder);
next.spec = _extends({}, this.spec);

@@ -30,0 +31,0 @@ return next;

@@ -87,2 +87,11 @@ import { Message } from './types';

}
export interface LocaleObject {
mixed?: MixedLocale;
string?: StringLocale;
number?: NumberLocale;
date?: DateLocale;
boolean?: BooleanLocale;
object?: ObjectLocale;
array?: ArrayLocale;
}
export declare let mixed: Required<MixedLocale>;

@@ -89,0 +98,0 @@ export declare let string: Required<StringLocale>;

@@ -53,3 +53,3 @@ import printValue from './util/printValue';

max: '${path} field must have less than or equal to ${max} items',
length: '${path} must be have ${length} items'
length: '${path} must have ${length} items'
};

@@ -56,0 +56,0 @@ export default Object.assign(Object.create(null), {

@@ -1,21 +0,23 @@

import { Maybe, Message, Optionals } from './types';
import type { Config, Defined, Thunk, ToggleDefault } from './util/types';
import { AnyObject, Maybe, Message, Optionals } from './types';
import type { Defined, Flags, SetFlag, Thunk, ToggleDefault, UnsetFlag } from './util/types';
import BaseSchema from './schema';
export declare class MixedSchema<TType = any, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
default<D extends Maybe<TType>>(def: Thunk<D>): MixedSchema<TType, ToggleDefault<TConfig, D>>;
concat<IT, IC extends Config<any, any>>(schema: MixedSchema<IT, IC>): MixedSchema<NonNullable<TType> | IT, TConfig & IC>;
concat<IT, IC extends Config<any, any>>(schema: BaseSchema<IT, IC>): MixedSchema<NonNullable<TType> | Optionals<IT>, TConfig & IC>;
export declare class MixedSchema<TType = any, TContext = AnyObject, TDefault = undefined, TFlags extends Flags = ''> extends BaseSchema<TType, TContext, TDefault, TFlags> {
default<D extends Maybe<TType>>(def: Thunk<D>): MixedSchema<TType, TContext, D, ToggleDefault<TFlags, D>>;
concat<IT, IC, ID, IF extends Flags>(schema: MixedSchema<IT, IC, ID, IF>): MixedSchema<NonNullable<TType> | IT, TContext & IC, ID, TFlags | IF>;
concat<IT, IC, ID, IF extends Flags>(schema: BaseSchema<IT, IC, ID, IF>): MixedSchema<NonNullable<TType> | Optionals<IT>, TContext & IC, ID, TFlags | IF>;
concat(schema: this): this;
defined(msg?: Message): MixedSchema<Defined<TType>, TConfig>;
optional(): MixedSchema<TType | undefined, TConfig>;
required(msg?: Message): MixedSchema<NonNullable<TType>, TConfig>;
notRequired(): MixedSchema<Maybe<TType>, TConfig>;
nullable(msg?: Message): MixedSchema<TType | null, TConfig>;
nonNullable(): MixedSchema<Exclude<TType, null>, TConfig>;
defined(msg?: Message): MixedSchema<Defined<TType>, TContext, TDefault, TFlags>;
optional(): MixedSchema<TType | undefined, TContext, TDefault, TFlags>;
required(msg?: Message): MixedSchema<NonNullable<TType>, TContext, TDefault, TFlags>;
notRequired(): MixedSchema<Maybe<TType>, TContext, TDefault, TFlags>;
nullable(msg?: Message): MixedSchema<TType | null, TContext, TDefault, TFlags>;
nonNullable(): MixedSchema<Exclude<TType, null>, TContext, TDefault, TFlags>;
strip(enabled: false): MixedSchema<TType, TContext, TDefault, UnsetFlag<TFlags, 's'>>;
strip(enabled?: true): MixedSchema<TType, TContext, TDefault, SetFlag<TFlags, 's'>>;
}
declare const Mixed: typeof MixedSchema;
export default Mixed;
export declare function create<TType = any>(): MixedSchema<TType | undefined, Config<Record<string, any>, "">>;
export declare function create<TType = any>(): MixedSchema<TType | undefined, AnyObject, undefined, "">;
export declare namespace create {
var prototype: MixedSchema<any, any>;
var prototype: MixedSchema<any, any, any, any>;
}
import type { AnyObject, Maybe, Message } from './types';
import type Reference from './Reference';
import type { AnyConfig, Config, Defined, MergeConfig, NotNull, SetFlag, Thunk, ToggleDefault } from './util/types';
import type { Concat, Defined, Flags, NotNull, SetFlag, Thunk, ToggleDefault, UnsetFlag } from './util/types';
import BaseSchema from './schema';
export declare function create(): NumberSchema;
export declare function create<T extends number, TContext = AnyObject>(): NumberSchema<T | undefined, TContext>;
export declare namespace create {
var prototype: NumberSchema<any, any>;
var prototype: NumberSchema<any, any, any, any>;
}
export declare function create<T extends number, TContext = AnyObject>(): NumberSchema<T | undefined, Config<TContext>>;
export declare namespace create {
var prototype: NumberSchema<any, any>;
}
export default class NumberSchema<TType extends Maybe<number> = number | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
export default class NumberSchema<TType extends Maybe<number> = number | undefined, TContext = AnyObject, TDefault = undefined, TFlags extends Flags = ''> extends BaseSchema<TType, TContext, TDefault, TFlags> {
constructor();

@@ -36,15 +33,16 @@ protected _typeCheck(value: any): value is NonNullable<TType>;

truncate(): this;
round(method: 'ceil' | 'floor' | 'round' | 'trunc'): this;
round(method?: 'ceil' | 'floor' | 'round' | 'trunc'): this;
}
export default interface NumberSchema<TType extends Maybe<number> = number | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
strip(): NumberSchema<TType, SetFlag<TConfig, 's'>>;
default<D extends Maybe<TType>>(def: Thunk<D>): NumberSchema<TType, ToggleDefault<TConfig, D>>;
concat<T extends Maybe<number>, C extends AnyConfig>(schema: NumberSchema<T, C>): NumberSchema<NonNullable<TType> | T, MergeConfig<TConfig, C>>;
export default interface NumberSchema<TType extends Maybe<number> = number | undefined, TContext = AnyObject, TDefault = undefined, TFlags extends Flags = ''> extends BaseSchema<TType, TContext, TDefault, TFlags> {
default<D extends Maybe<TType>>(def: Thunk<D>): NumberSchema<TType, TContext, D, ToggleDefault<TFlags, D>>;
concat<UType extends Maybe<number>, UContext, UFlags extends Flags, UDefault>(schema: NumberSchema<UType, UContext, UDefault, UFlags>): NumberSchema<Concat<TType, UType>, TContext & UContext, UDefault, TFlags | UFlags>;
concat(schema: this): this;
defined(msg?: Message): NumberSchema<Defined<TType>, TConfig>;
optional(): NumberSchema<TType | undefined, TConfig>;
required(msg?: Message): NumberSchema<NonNullable<TType>, TConfig>;
notRequired(): NumberSchema<Maybe<TType>, TConfig>;
nullable(msg?: Message): NumberSchema<TType | null, TConfig>;
nonNullable(): NumberSchema<NotNull<TType>, TConfig>;
defined(msg?: Message): NumberSchema<Defined<TType>, TContext, TDefault, TFlags>;
optional(): NumberSchema<TType | undefined, TContext, TDefault, TFlags>;
required(msg?: Message): NumberSchema<NonNullable<TType>, TContext, TDefault, TFlags>;
notRequired(): NumberSchema<Maybe<TType>, TContext, TDefault, TFlags>;
nullable(msg?: Message): NumberSchema<TType | null, TContext, TDefault, TFlags>;
nonNullable(): NumberSchema<NotNull<TType>, TContext, TDefault, TFlags>;
strip(enabled: false): NumberSchema<TType, TContext, TDefault, UnsetFlag<TFlags, 's'>>;
strip(enabled?: true): NumberSchema<TType, TContext, TDefault, SetFlag<TFlags, 's'>>;
}

@@ -1,37 +0,33 @@

import { InternalOptions, Callback, Maybe, Optionals, Preserve, Message } from './types';
import type { TypedSchema, Defined, Thunk, Config, NotNull, ToggleDefault, _, MakePartial } from './util/types';
import { Flags, ISchema, SetFlag, ToggleDefault, UnsetFlag } from './util/types';
import { InternalOptions, Callback, Maybe, Message } from './types';
import type { Defined, Thunk, NotNull, _ } from './util/types';
import type Reference from './Reference';
import Lazy from './Lazy';
import BaseSchema, { AnySchema, SchemaObjectDescription, SchemaSpec } from './schema';
import BaseSchema, { SchemaObjectDescription, SchemaSpec } from './schema';
import { ResolveOptions } from './Condition';
export declare type Assign<T extends {}, U extends {}> = {
[P in keyof T]: P extends keyof U ? U[P] : T[P];
} & U;
export declare type AnyObject = Record<string, any>;
export declare type ObjectShape = Record<string, AnySchema | Reference | Lazy<any, any>>;
declare type FieldType<T extends AnySchema | Reference | Lazy<any, any>, F extends '__type' | '__outputType'> = T extends TypedSchema ? T[F] : T extends Reference ? unknown : never;
export declare type DefaultFromShape<Shape extends ObjectShape> = {
[K in keyof Shape]: Shape[K] extends ObjectSchema<infer TShape> ? DefaultFromShape<TShape> : Shape[K] extends {
getDefault: () => infer D;
} ? Preserve<D, undefined> extends never ? Defined<D> : Preserve<D, undefined> : undefined;
import type { AnyObject, DefaultFromShape, MakePartial, ObjectShape, PartialDeep, TypeFromShape } from './util/objectTypes';
export type { AnyObject };
declare type MakeKeysOptional<T> = T extends AnyObject ? _<MakePartial<T>> : T;
export declare type Shape<T extends Maybe<AnyObject>, C = AnyObject> = {
[field in keyof T]: ISchema<T[field], C> | Reference;
};
export declare type TypeOfShape<Shape extends ObjectShape> = {
[K in keyof Shape]: FieldType<Shape[K], '__type'>;
};
export declare type AssertsShape<S extends ObjectShape> = MakePartial<{
[K in keyof S]: FieldType<S[K], '__outputType'>;
}> & {
[k: string]: any;
};
export declare type PartialSchema<S extends ObjectShape> = {
[K in keyof S]: S[K] extends BaseSchema ? ReturnType<S[K]['optional']> : S[K];
};
export declare type DeepPartialSchema<S extends ObjectShape> = {
[K in keyof S]: S[K] extends ObjectSchema<any, any, any> ? ReturnType<S[K]['deepPartial']> : S[K] extends BaseSchema ? ReturnType<S[K]['optional']> : S[K];
};
export declare type ObjectSchemaSpec = SchemaSpec<any> & {
noUnknown?: boolean;
};
export default class ObjectSchema<TShape extends ObjectShape, TConfig extends Config<any, any> = Config<AnyObject, 'd'>, TIn extends Maybe<AssertsShape<TShape>> = AssertsShape<TShape> | undefined> extends BaseSchema<TIn, TConfig> {
fields: TShape;
export declare function create<C = AnyObject, S extends ObjectShape = {}>(spec?: S): ObjectSchema<_<TypeFromShape<S, C>>, C, _<DefaultFromShape<S>>, "d">;
export declare namespace create {
var prototype: ObjectSchema<any, any, any, any>;
}
export default interface ObjectSchema<TIn extends Maybe<AnyObject>, TContext = AnyObject, TDefault = any, TFlags extends Flags = 'd'> extends BaseSchema<MakeKeysOptional<TIn>, TContext, TDefault, TFlags> {
default<D extends Maybe<AnyObject>>(def: Thunk<D>): ObjectSchema<TIn, TContext, D, ToggleDefault<TFlags, 'd'>>;
defined(msg?: Message): ObjectSchema<Defined<TIn>, TContext, TDefault, TFlags>;
optional(): ObjectSchema<TIn | undefined, TContext, TDefault, TFlags>;
required(msg?: Message): ObjectSchema<NonNullable<TIn>, TContext, TDefault, TFlags>;
notRequired(): ObjectSchema<Maybe<TIn>, TContext, TDefault, TFlags>;
nullable(msg?: Message): ObjectSchema<TIn | null, TContext, TDefault, TFlags>;
nonNullable(): ObjectSchema<NotNull<TIn>, TContext, TDefault, TFlags>;
strip(enabled: false): ObjectSchema<TIn, TContext, TDefault, UnsetFlag<TFlags, 's'>>;
strip(enabled?: true): ObjectSchema<TIn, TContext, TDefault, SetFlag<TFlags, 's'>>;
}
export default class ObjectSchema<TIn extends Maybe<AnyObject>, TContext = AnyObject, TDefault = any, TFlags extends Flags = 'd'> extends BaseSchema<MakeKeysOptional<TIn>, TContext, TDefault, TFlags> {
fields: Shape<NonNullable<TIn>, TContext>;
spec: ObjectSchemaSpec;

@@ -41,19 +37,19 @@ private _sortErrors;

private _excludedEdges;
constructor(spec?: TShape);
protected _typeCheck(value: any): value is NonNullable<TIn>;
protected _cast(_value: any, options?: InternalOptions<TConfig['context']>): any;
protected _validate(_value: any, opts: InternalOptions<TConfig["context"]> | undefined, callback: Callback): void;
constructor(spec?: Shape<TIn, TContext>);
protected _typeCheck(value: any): value is NonNullable<MakeKeysOptional<TIn>>;
protected _cast(_value: any, options?: InternalOptions<TContext>): any;
protected _validate(_value: any, opts: InternalOptions<TContext> | undefined, callback: Callback): void;
clone(spec?: ObjectSchemaSpec): this;
concat<TOther extends ObjectSchema<any, any, any>>(schema: TOther): TOther extends ObjectSchema<infer S, infer C, infer IType> ? ObjectSchema<TShape & S, TConfig & C, AssertsShape<TShape & S> | Optionals<IType>> : never;
concat<IIn, IC, ID, IF extends Flags>(schema: ObjectSchema<IIn, IC, ID, IF>): ObjectSchema<NonNullable<TIn> | IIn, TContext & IC, TDefault & ID, TFlags | IF>;
concat(schema: this): this;
protected _getDefault(): any;
getDefaultFromShape(): _<DefaultFromShape<TShape>>;
private setFields;
shape<TNextShape extends ObjectShape>(additions: TNextShape, excludes?: [string, string][]): ObjectSchema<Assign<TShape, TNextShape>, TConfig, Extract<TIn, null | undefined> | AssertsShape<Assign<TShape, TNextShape>>>;
partial(): ObjectSchema<PartialSchema<TShape>, TConfig, Extract<TIn, null | undefined> | AssertsShape<PartialSchema<TShape>>>;
deepPartial(): ObjectSchema<DeepPartialSchema<TShape>, TConfig, Optionals<TIn> | undefined | AssertsShape<DeepPartialSchema<TShape>>>;
pick<TKey extends keyof TShape>(keys: TKey[]): ObjectSchema<Pick<TShape, TKey>, TConfig, Extract<TIn, null | undefined> | AssertsShape<Pick<TShape, TKey>>>;
omit<TKey extends keyof TShape>(keys: TKey[]): ObjectSchema<Pick<TShape, Exclude<keyof TShape, TKey>>, TConfig, Extract<TIn, null | undefined> | AssertsShape<Pick<TShape, Exclude<keyof TShape, TKey>>>>;
from(from: string, to: keyof TShape, alias?: boolean): this;
noUnknown(noAllow?: boolean, message?: Message<any>): this;
shape<U extends ObjectShape>(additions: U, excludes?: [string, string][]): ObjectSchema<_<{ [P in keyof TIn]: P extends keyof U ? TypeFromShape<U, TContext>[P] : TIn[P]; } & TypeFromShape<U, TContext>> | _<Extract<TIn, null | undefined>>, TContext, Extract<TFlags, "d"> extends never ? _<TDefault & DefaultFromShape<U>> : TDefault, TFlags>;
partial(): ObjectSchema<Partial<TIn>, TContext, TDefault, TFlags>;
deepPartial(): ObjectSchema<PartialDeep<TIn>, TContext, TDefault, TFlags>;
pick<TKey extends keyof TIn>(keys: TKey[]): ObjectSchema<{ [K in TKey]: TIn[K]; }, TContext, TDefault, TFlags>;
omit<TKey extends keyof TIn>(keys: TKey[]): ObjectSchema<Omit<TIn, TKey>, TContext, TDefault, TFlags>;
from(from: string, to: keyof TIn, alias?: boolean): this;
noUnknown(message?: Message): this;
noUnknown(noAllow: boolean, message?: Message): this;
unknown(allow?: boolean, message?: Message<any>): this;

@@ -64,17 +60,3 @@ transformKeys(fn: (key: string) => string): this;

constantCase(): this;
describe(options?: ResolveOptions<TConfig['context']>): SchemaObjectDescription;
describe(options?: ResolveOptions<TContext>): SchemaObjectDescription;
}
export declare function create<TShape extends ObjectShape = {}>(spec?: TShape): ObjectSchema<TShape, Config<Record<string, any>, "d">, AssertsShape<TShape> | undefined>;
export declare namespace create {
var prototype: ObjectSchema<any, any, any>;
}
export default interface ObjectSchema<TShape extends ObjectShape, TConfig extends Config<any, any> = Config<AnyObject, 'd'>, TIn extends Maybe<AssertsShape<TShape>> = AssertsShape<TShape> | undefined> extends BaseSchema<TIn, TConfig> {
default<D extends Maybe<AnyObject>>(def: Thunk<D>): ObjectSchema<TShape, ToggleDefault<TConfig, D>, TIn>;
defined(msg?: Message): ObjectSchema<TShape, TConfig, Defined<TIn>>;
optional(): ObjectSchema<TShape, TConfig, TIn | undefined>;
required(msg?: Message): ObjectSchema<TShape, TConfig, NonNullable<TIn>>;
notRequired(): ObjectSchema<TShape, TConfig, Maybe<TIn>>;
nullable(isNullable?: true): ObjectSchema<TShape, TConfig, TIn | null>;
nullable(isNullable: false): ObjectSchema<TShape, TConfig, NotNull<TIn>>;
}
export {};

@@ -29,3 +29,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

const defaultSort = sortByKeyOrder([]);
export function create(spec) {
return new ObjectSchema(spec);
}
export default class ObjectSchema extends BaseSchema {
//readonly (keyof TIn & string)[]
constructor(spec) {

@@ -73,5 +77,3 @@ super({

let strip = (_options$stripUnknown = options.stripUnknown) != null ? _options$stripUnknown : this.spec.noUnknown;
let props = this._nodes.concat(Object.keys(value).filter(v => this._nodes.indexOf(v) === -1));
let props = [].concat(this._nodes, Object.keys(value).filter(v => !this._nodes.includes(v)));
let intermediateValue = {}; // is filled during the transform below

@@ -219,3 +221,3 @@

return next.withMutation(s => s.setFields(nextFields));
return next.withMutation(s => s.setFields(nextFields, this._excludedEdges));
}

@@ -233,6 +235,2 @@

return this.getDefaultFromShape();
}
getDefaultFromShape() {
let dft = {};

@@ -242,3 +240,3 @@

const field = this.fields[key];
dft[key] = 'default' in field ? field.getDefault() : undefined;
dft[key] = 'getDefault' in field ? field.getDefault() : undefined;
});

@@ -265,4 +263,3 @@

if (!Array.isArray(excludes[0])) excludes = [excludes];
let keys = excludes.map(([first, second]) => `${first}-${second}`);
edges = edges.concat(keys);
edges = [...next._excludedEdges, ...excludes];
} // XXX: excludes here is wrong

@@ -332,3 +329,3 @@

noUnknown(noAllow = true, message = locale.noUnknown) {
if (typeof noAllow === 'string') {
if (typeof noAllow !== 'boolean') {
message = noAllow;

@@ -408,5 +405,2 @@ noAllow = true;

}
export function create(spec) {
return new ObjectSchema(spec);
}
create.prototype = ObjectSchema.prototype;

@@ -5,3 +5,3 @@ import type { SchemaRefDescription } from './schema';

};
export declare function create(key: string, options?: ReferenceOptions): Reference<unknown>;
export declare function create<TValue = unknown>(key: string, options?: ReferenceOptions<TValue>): Reference<TValue>;
export default class Reference<TValue = unknown> {

@@ -8,0 +8,0 @@ readonly key: string;

@@ -11,2 +11,9 @@ import { getter } from 'property-expr';

constructor(key, options = {}) {
this.key = void 0;
this.isContext = void 0;
this.isValue = void 0;
this.isSibling = void 0;
this.path = void 0;
this.getter = void 0;
this.map = void 0;
if (typeof key !== 'string') throw new TypeError('ref must be a string, got: ' + key);

@@ -13,0 +20,0 @@ this.key = key.trim();

import { ConditionOptions, ResolveOptions } from './Condition';
import { TestFunction, Test, TestConfig } from './util/createValidation';
import { ValidateOptions, TransformFunction, Message, Callback, InternalOptions, Maybe, ExtraParams, Preserve } from './types';
import { ValidateOptions, TransformFunction, Message, Callback, InternalOptions, Maybe, ExtraParams, AnyObject } from './types';
import ReferenceSet from './util/ReferenceSet';
import Reference from './Reference';
import { Config, Defined, Flags, SetFlag, Thunk, _ } from './util/types';
export { Config };
export declare type ConfigOf<T> = T extends AnySchema<any, infer C> ? C : never;
export declare type ContextOf<T> = ConfigOf<T>['context'];
export declare type FlagsOf<T> = T extends AnySchema ? T['__flags'] : never;
export declare type HasFlag<T, F extends Flags> = F extends FlagsOf<T> ? true : never;
export declare type ResolveFlags<T, F extends Flags> = Preserve<F, 'd'> extends never ? T : Defined<T>;
import type { Defined, Flags, ISchema, ResolveFlags, Thunk } from './util/types';
export declare type SchemaSpec<TDefault> = {

@@ -28,3 +22,3 @@ nullable: boolean;

};
export declare type AnySchema<TType = any, C extends Config = any> = BaseSchema<TType, C>;
export declare type AnySchema<TType = any, C = AnyObject, D = any, F extends Flags = Flags> = BaseSchema<TType, C, D, F>;
export interface CastOptions<C = {}> {

@@ -67,8 +61,9 @@ parent?: any;

}
export default abstract class BaseSchema<TType = any, TConfig extends Config<any, any> = Config> {
export default abstract class BaseSchema<TType = any, TContext = AnyObject, TDefault = any, TFlags extends Flags = ''> implements ISchema<TType, TContext, TFlags, TDefault> {
readonly type: string;
readonly __type: TType;
readonly __outputType: ResolveFlags<TType, TConfig['flags']>;
readonly __flags: TConfig['flags'];
readonly __outputType: ResolveFlags<TType, TFlags>;
readonly __context: TContext;
readonly __flags: TFlags;
readonly __isYupSchema__: boolean;
readonly __default: TDefault;
readonly deps: readonly string[];

@@ -95,3 +90,3 @@ tests: Test[];

isType(v: unknown): v is TType;
resolve(options: ResolveOptions): this;
resolve(options: ResolveOptions<TContext>): this;
/**

@@ -104,11 +99,11 @@ *

*/
cast(value: any, options?: CastOptions<TConfig['context']>): _<this['__outputType']>;
protected _cast(rawValue: any, _options: CastOptions<TConfig['context']>): any;
protected _validate(_value: any, options: InternalOptions<TConfig["context"]> | undefined, cb: Callback): void;
validate(value: any, options?: ValidateOptions<TConfig['context']>): Promise<_<this['__outputType']>>;
validateSync(value: any, options?: ValidateOptions<TConfig['context']>): _<this['__outputType']>;
isValid(value: any, options?: ValidateOptions<TConfig['context']>): Promise<boolean>;
isValidSync(value: any, options?: ValidateOptions<TConfig['context']>): value is this['__outputType'];
cast(value: any, options?: CastOptions<TContext>): this['__outputType'];
protected _cast(rawValue: any, _options: CastOptions<TContext>): any;
protected _validate(_value: any, options: InternalOptions<TContext> | undefined, cb: Callback): void;
validate(value: any, options?: ValidateOptions<TContext>): Promise<this['__outputType']>;
validateSync(value: any, options?: ValidateOptions<TContext>): this['__outputType'];
isValid(value: any, options?: ValidateOptions<TContext>): Promise<boolean>;
isValidSync(value: any, options?: ValidateOptions<TContext>): value is this['__outputType'];
protected _getDefault(): any;
getDefault(options?: ResolveOptions): Preserve<TConfig['flags'], 'd'> extends never ? undefined : Defined<TType>;
getDefault(options?: ResolveOptions<TContext>): TDefault;
default(def: Thunk<any>): any;

@@ -139,6 +134,6 @@ strict(isStrict?: boolean): this;

*/
test(options: TestConfig<this['__outputType'], TConfig['context']>): this;
test(test: TestFunction<this['__outputType'], TConfig['context']>): this;
test(name: string, test: TestFunction<this['__outputType'], TConfig['context']>): this;
test(name: string, message: Message, test: TestFunction<this['__outputType'], TConfig['context']>): this;
test(options: TestConfig<this['__outputType'], TContext>): this;
test(test: TestFunction<this['__outputType'], TContext>): this;
test(name: string, test: TestFunction<this['__outputType'], TContext>): this;
test(name: string, message: Message, test: TestFunction<this['__outputType'], TContext>): this;
when(options: ConditionOptions<this>): this;

@@ -153,3 +148,3 @@ when(keys: string | string[], options: ConditionOptions<this>): this;

}>): this;
strip(strip?: boolean): BaseSchema<TType, SetFlag<TConfig, 's'>>;
strip(strip?: boolean): any;
/**

@@ -160,7 +155,7 @@ * Return a serialized description of the schema including validations, flags, types etc.

*/
describe(options?: ResolveOptions<TConfig['context']>): SchemaDescription;
describe(options?: ResolveOptions<TContext>): SchemaDescription;
}
export default interface BaseSchema<TType = any, TConfig extends Config<any, any> = Config> {
validateAt(path: string, value: any, options?: ValidateOptions<TConfig['context']>): Promise<any>;
validateSyncAt(path: string, value: any, options?: ValidateOptions<TConfig['context']>): any;
export default interface BaseSchema<TType = any, TContext = AnyObject, TDefault = any, TFlags extends Flags = ''> {
validateAt(path: string, value: any, options?: ValidateOptions<TContext>): Promise<any>;
validateSyncAt(path: string, value: any, options?: ValidateOptions<TContext>): any;
equals: BaseSchema['oneOf'];

@@ -167,0 +162,0 @@ is: BaseSchema['oneOf'];

@@ -12,12 +12,14 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

import { getIn } from './util/reach';
import toArray from './util/toArray';
import ValidationError from './ValidationError';
import ReferenceSet from './util/ReferenceSet';
import isAbsent from './util/isAbsent';
import { Config } from './util/types';
export { Config };
import toArray from './util/toArray';
export default class BaseSchema {
constructor(options) {
this.type = void 0;
this.deps = [];
this.tests = void 0;
this.transforms = void 0;
this.conditions = [];
this._mutate = void 0;
this.internalTests = {};

@@ -27,2 +29,3 @@ this._whitelist = new ReferenceSet();

this.exclusiveTests = Object.create(null);
this.spec = void 0;
this.tests = [];

@@ -91,11 +94,4 @@ this.transforms = [];

return next;
} // withContext<C extends AnyObject>(): BaseSchema<
// TType,
// C,
// TOut
// > {
// return this as any;
// }
}
withMutation(fn) {

@@ -115,8 +111,4 @@ let before = this._mutate;

const mergedSpec = _extends({}, base.spec, combined.spec); // if (combined.spec.nullable === UNSET)
// mergedSpec.nullable = base.spec.nullable;
// if (combined.spec.presence === UNSET)
// mergedSpec.presence = base.spec.presence;
const mergedSpec = _extends({}, base.spec, combined.spec);
combined.spec = mergedSpec;

@@ -138,2 +130,3 @@ combined.internalTests = _extends({}, base.internalTests, combined.internalTests); // manually merge the blacklist/whitelist (the other `schema` takes

});
combined.transforms = [...base.transforms, ...combined.transforms];
return combined;

@@ -253,3 +246,3 @@ }

});
} // validate<U extends TType>(value: U, options?: ValidateOptions<TConfig['context']>): Promise<U>;
} // validate<U extends TType>(value: U, options?: ValidateOptions<TContext>): Promise<U>;

@@ -265,3 +258,3 @@

}));
} // validateSync<U extends TType>(value: U, options?: ValidateOptions<TConfig['context']>): U;
} // validateSync<U extends TType>(value: U, options?: ValidateOptions<TContext>): U;

@@ -312,3 +305,4 @@

getDefault(options) {
getDefault(options // If schema is defaulted we know it's at least not undefined
) {
let schema = this.resolve(options || {});

@@ -526,5 +520,7 @@ return schema._getDefault();

let valids = this.schema._whitelist;
return valids.has(value, this.resolve) ? true : this.createError({
let resolved = valids.resolveAll(this.resolve);
return resolved.includes(value) ? true : this.createError({
params: {
values: valids.toArray().join(', ')
values: valids.toArray().join(', '),
resolved
}

@@ -551,5 +547,7 @@ });

let invalids = this.schema._blacklist;
if (invalids.has(value, this.resolve)) return this.createError({
let resolved = invalids.resolveAll(this.resolve);
if (resolved.includes(value)) return this.createError({
params: {
values: invalids.toArray().join(', ')
values: invalids.toArray().join(', '),
resolved
}

@@ -562,4 +560,5 @@ });

return next;
}
} //BaseSchema<TType, SetFlag<TFlags, 's'>>
strip(strip = true) {

@@ -566,0 +565,0 @@ let next = this.clone();

import { MixedLocale } from './locale';
import type Reference from './Reference';
import type { Message, Maybe, AnyObject, Optionals } from './types';
import type { AnyConfig, Defined, MergeConfig, NotNull, SetFlag, Thunk, ToggleDefault } from './util/types';
import BaseSchema, { Config } from './schema';
import type { Concat, Defined, Flags, NotNull, SetFlag, Thunk, ToggleDefault, UnsetFlag } from './util/types';
import BaseSchema from './schema';
export declare type MatchOptions = {

@@ -14,11 +14,8 @@ excludeEmptyString?: boolean;

declare function create(): StringSchema;
declare function create<T extends string, TContext = AnyObject>(): StringSchema<T | undefined, TContext>;
declare namespace create {
var prototype: StringSchema<any, any>;
var prototype: StringSchema<any, any, any, any>;
}
declare function create<T extends string, TContext = AnyObject>(): StringSchema<T | undefined, Config<TContext>>;
declare namespace create {
var prototype: StringSchema<any, any>;
}
export { create };
export default class StringSchema<TType extends Maybe<string> = string | undefined, TConfig extends AnyConfig = Config> extends BaseSchema<TType, TConfig> {
export default class StringSchema<TType extends Maybe<string> = string | undefined, TContext = AnyObject, TDefault = undefined, TFlags extends Flags = ''> extends BaseSchema<TType, TContext, TDefault, TFlags> {
constructor();

@@ -51,14 +48,15 @@ protected _typeCheck(value: any): value is NonNullable<TType>;

}
export default interface StringSchema<TType extends Maybe<string> = string | undefined, TConfig extends AnyConfig = Config> extends BaseSchema<TType, TConfig> {
default<D extends Maybe<TType>>(def: Thunk<D>): StringSchema<TType, ToggleDefault<TConfig, D>>;
oneOf<U extends TType>(arrayOfValues: ReadonlyArray<U | Reference>, message?: MixedLocale['oneOf']): StringSchema<U | Optionals<TType>, TConfig>;
concat<T extends Maybe<string>, C extends AnyConfig>(schema: StringSchema<T, C>): StringSchema<NonNullable<TType> | T, MergeConfig<TConfig, C>>;
export default interface StringSchema<TType extends Maybe<string> = string | undefined, TContext = AnyObject, TDefault = undefined, TFlags extends Flags = ''> extends BaseSchema<TType, TContext, TDefault, TFlags> {
default<D extends Maybe<TType>>(def: Thunk<D>): StringSchema<TType, TContext, D, ToggleDefault<TFlags, D>>;
oneOf<U extends TType>(arrayOfValues: ReadonlyArray<U | Reference>, message?: MixedLocale['oneOf']): StringSchema<U | Optionals<TType>, TContext, TDefault, TFlags>;
concat<UType extends Maybe<string>, UContext, UDefault, UFlags extends Flags>(schema: StringSchema<UType, UContext, UDefault, UFlags>): StringSchema<Concat<TType, UType>, TContext & UContext, UDefault, TFlags | UFlags>;
concat(schema: this): this;
defined(msg?: Message): StringSchema<Defined<TType>, TConfig>;
optional(): StringSchema<TType | undefined, TConfig>;
required(msg?: Message): StringSchema<NonNullable<TType>, TConfig>;
notRequired(): StringSchema<Maybe<TType>, TConfig>;
nullable(msg?: Message<any>): StringSchema<TType | null, TConfig>;
nonNullable(): StringSchema<NotNull<TType>, TConfig>;
strip(): StringSchema<TType, SetFlag<TConfig, 's'>>;
defined(msg?: Message): StringSchema<Defined<TType>, TContext, TDefault, TFlags>;
optional(): StringSchema<TType | undefined, TContext, TDefault, TFlags>;
required(msg?: Message): StringSchema<NonNullable<TType>, TContext, TDefault, TFlags>;
notRequired(): StringSchema<Maybe<TType>, TContext, TDefault, TFlags>;
nullable(msg?: Message<any>): StringSchema<TType | null, TContext, TDefault, TFlags>;
nonNullable(): StringSchema<NotNull<TType>, TContext, TDefault, TFlags>;
strip(enabled: false): StringSchema<TType, TContext, TDefault, UnsetFlag<TFlags, 's'>>;
strip(enabled?: true): StringSchema<TType, TContext, TDefault, SetFlag<TFlags, 's'>>;
}
import { string as locale } from './locale';
import isAbsent from './util/isAbsent';
import BaseSchema from './schema'; // eslint-disable-next-line
import BaseSchema from './schema';
let rEmail = // eslint-disable-next-line
/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
let rUrl = // eslint-disable-next-line
/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i; // eslint-disable-next-line
let rEmail = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i; // eslint-disable-next-line
let rUrl = /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i; // eslint-disable-next-line
let rUUID = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;

@@ -10,0 +10,0 @@

import type { AnySchema } from './schema';
import type Lazy from './Lazy';
export declare type AnyObject = Record<string, any>;
export declare type SchemaLike = AnySchema | Lazy<any>;
import type { AnyObject } from './util/objectTypes';
import type { ISchema } from './util/types';
export type { ISchema, AnyObject, AnySchema };
export declare type Callback<T = any> = (err: Error | null, value?: T) => void;

@@ -36,3 +36,3 @@ export declare type TransformFunction<T extends AnySchema> = (this: T, value: any, originalValue: any, schema: T) => any;

from?: {
schema: AnySchema;
schema: ISchema<any, TContext>;
value: any;

@@ -39,0 +39,0 @@ }[];

@@ -5,2 +5,3 @@ import ValidationError from '../ValidationError';

import type { AnySchema } from '../schema';
import { ISchema } from './types';
export declare type CreateErrorOptions = {

@@ -16,2 +17,6 @@ path?: string;

parent: any;
from?: Array<{
schema: ISchema<any, TContext>;
value: any;
}>;
schema: any;

@@ -21,3 +26,3 @@ resolve: <T>(value: T | Reference<T>) => T;

};
export declare type TestFunction<T = unknown, TContext = {}> = (this: TestContext<TContext>, value: T, context: TestContext<TContext>) => boolean | ValidationError | Promise<boolean | ValidationError>;
export declare type TestFunction<T = unknown, TContext = {}> = (this: TestContext<TContext>, value: T, context: TestContext<TContext>) => void | boolean | ValidationError | Promise<boolean | ValidationError>;
export declare type TestOptions<TSchema extends AnySchema = AnySchema> = {

@@ -48,9 +53,9 @@ value: any;

}): {
<TSchema extends AnySchema<any, any> = AnySchema<any, any>>({ value, path, label, options, originalValue, sync, ...rest }: TestOptions<TSchema>, cb: Callback): void;
<TSchema extends AnySchema<any, import("./objectTypes").AnyObject, any, import("./types").Flags> = AnySchema<any, import("./objectTypes").AnyObject, any, import("./types").Flags>>({ value, path, label, options, originalValue, sync, ...rest }: TestOptions<TSchema>, cb: Callback): void;
OPTIONS: {
name?: string | undefined;
test: TestFunction;
params?: Record<string, unknown> | undefined;
message?: string | Record<string | number | symbol, unknown> | ((params: any) => unknown) | undefined;
params?: ExtraParams | undefined;
message?: Message<any> | undefined;
};
};

@@ -63,3 +63,3 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

if (ValidationError.isError(validOrError)) cb(validOrError);else if (!validOrError) cb(createError());else cb(null, validOrError);
});
}).catch(cb);
} catch (err) {

@@ -66,0 +66,0 @@ cb(err);

@@ -1,2 +0,2 @@

declare const _default: (value: any) => value is null | undefined;
export default _default;
declare const isAbsent: (value: any) => value is null | undefined;
export default isAbsent;

@@ -1,1 +0,3 @@

export default (value => value == null);
const isAbsent = value => value == null;
export default isAbsent;

@@ -1,3 +0,3 @@

import type { SchemaLike } from '../types';
declare const _default: (obj: any) => obj is SchemaLike;
export default _default;
import type { ISchema } from './types';
declare const isSchema: (obj: any) => obj is ISchema<any, import("./objectTypes").AnyObject, any, any>;
export default isSchema;

@@ -1,1 +0,3 @@

export default (obj => obj && obj.__isYupSchema__);
const isSchema = obj => obj && obj.__isYupSchema__;
export default isSchema;

@@ -1,2 +0,2 @@

export declare function getIn(schema: any, path: string, value: any, context?: any): {
export declare function getIn(schema: any, path: string, value?: any, context?: any): {
parent: any;

@@ -6,3 +6,3 @@ parentPath: string;

};
declare const reach: (obj: {}, path: string, value: any, context: any) => any;
declare const reach: (obj: {}, path: string, value?: any, context?: any) => any;
export default reach;

@@ -9,7 +9,7 @@ import Reference from '../Reference';

toArray(): unknown[];
resolveAll(resolve: (v: unknown) => unknown): unknown;
add(value: unknown): void;
delete(value: unknown): void;
has(value: unknown, resolve: (v: unknown) => unknown): boolean;
clone(): ReferenceSet;
merge(newItems: ReferenceSet, removeItems: ReferenceSet): ReferenceSet;
}
import Reference from '../Reference';
export default class ReferenceSet {
constructor() {
this.list = void 0;
this.refs = void 0;
this.list = new Set();

@@ -26,2 +28,6 @@ this.refs = new Map();

resolveAll(resolve) {
return this.toArray().reduce((acc, e) => acc.concat(Reference.isRef(e) ? resolve(e) : e), []);
}
add(value) {

@@ -35,12 +41,2 @@ Reference.isRef(value) ? this.refs.set(value.key, value) : this.list.add(value);

has(value, resolve) {
if (this.list.has(value)) return true;
let item,
values = this.refs.values();
while (item = values.next(), !item.done) if (resolve(item.value) === value) return true;
return false;
}
clone() {

@@ -47,0 +43,0 @@ const next = new ReferenceSet();

@@ -1,2 +0,2 @@

import { ObjectShape } from '../object';
export default function sortFields(fields: ObjectShape, excludes?: readonly string[]): string[];
import { ObjectShape } from './objectTypes';
export default function sortFields(fields: ObjectShape, excludedEdges?: readonly [string, string][]): string[];

@@ -6,10 +6,11 @@ // @ts-expect-error

import isSchema from './isSchema';
export default function sortFields(fields, excludes = []) {
export default function sortFields(fields, excludedEdges = []) {
let edges = [];
let nodes = [];
let nodes = new Set();
let excludes = new Set(excludedEdges.map(([a, b]) => `${a}-${b}`));
function addNode(depPath, key) {
let node = split(depPath)[0];
if (!~nodes.indexOf(node)) nodes.push(node);
if (!~excludes.indexOf(`${key}-${node}`)) edges.push([key, node]);
nodes.add(node);
if (!excludes.has(`${key}-${node}`)) edges.push([key, node]);
}

@@ -19,7 +20,7 @@

let value = fields[key];
if (!~nodes.indexOf(key)) nodes.push(key);
nodes.add(key);
if (Ref.isRef(value) && value.isSibling) addNode(value.path, key);else if (isSchema(value) && 'deps' in value) value.deps.forEach(path => addNode(path, key));
}
return toposort.array(nodes, edges).reverse();
return toposort.array(Array.from(nodes), edges).reverse();
}

@@ -1,34 +0,26 @@

import type { AnyObject, Preserve } from '../types';
import type { ResolveOptions } from '../Condition';
import type { CastOptions, SchemaFieldDescription } from '../schema';
import type { AnyObject, Callback, Optionals, Preserve, ValidateOptions } from '../types';
export declare type Defined<T> = T extends undefined ? never : T;
export declare type NotNull<T> = T extends null ? never : T;
export declare type TypedSchema = {
__type: any;
__outputType: any;
};
export declare type TypeOf<TSchema extends TypedSchema> = TSchema['__type'];
export declare type Asserts<TSchema extends TypedSchema> = TSchema['__outputType'];
export interface ISchema<T, C = AnyObject, F extends Flags = any, D = any> {
__flags: F;
__context: C;
__outputType: T;
__default: D;
cast(value: any, options?: CastOptions<C>): T;
validate(value: any, options?: ValidateOptions<C>, maybeCb?: Callback): Promise<T>;
describe(options?: ResolveOptions<C>): SchemaFieldDescription;
resolve(options: ResolveOptions<C>): ISchema<T, C, F>;
}
export declare type InferType<T extends ISchema<any, any>> = T['__outputType'];
export declare type Thunk<T> = T | (() => T);
export declare type If<T, Y, N> = Exclude<T, undefined> extends never ? Y : N;
export declare type _<T> = T extends {} ? {
[k in keyof T]: _<T[k]>;
[k in keyof T]: T[k];
} : T;
declare type OptionalKeys<T extends {}> = {
[k in keyof T]: undefined extends T[k] ? k : never;
}[keyof T];
declare type RequiredKeys<T extends object> = Exclude<keyof T, OptionalKeys<T>>;
export declare type MakePartial<T extends object> = {
[k in OptionalKeys<T>]?: T[k];
} & {
[k in RequiredKeys<T>]: T[k];
};
export declare type Flags = 's' | 'd' | '';
export interface Config<C = AnyObject, F extends Flags = ''> {
context: C;
flags: F;
}
export declare type AnyConfig = Config<any, any>;
export declare type MergeConfig<T extends AnyConfig, U extends AnyConfig> = Config<T['context'] & U['context'], T['flags'] | U['flags']>;
export declare type SetFlag<C extends AnyConfig, F extends Flags> = C extends Config<infer Context, infer Old> ? Config<Context, Exclude<Old, ''> | F> : never;
export declare type UnsetFlag<C extends AnyConfig, F extends Flags> = C extends Config<infer Context, infer Old> ? Exclude<Old, F> extends never ? Config<Context, ''> : Config<Context, Exclude<Old, F>> : never;
export declare type ToggleDefault<C extends AnyConfig, D> = Preserve<D, undefined> extends never ? SetFlag<C, 'd'> : UnsetFlag<C, 'd'>;
export {};
export declare type SetFlag<Old extends Flags, F extends Flags> = Exclude<Old, ''> | F;
export declare type UnsetFlag<Old extends Flags, F extends Flags> = Exclude<Old, F> extends never ? '' : Exclude<Old, F>;
export declare type ToggleDefault<F extends Flags, D> = Preserve<D, undefined> extends never ? SetFlag<F, 'd'> : UnsetFlag<F, 'd'>;
export declare type ResolveFlags<T, F extends Flags> = Preserve<F, 's'> extends never ? Extract<F, 'd'> extends never ? T : Defined<T> : never;
export declare type Concat<T, U> = NonNullable<T> & NonNullable<U> extends never ? never : (NonNullable<T> & NonNullable<U>) | Optionals<U>;

@@ -23,2 +23,8 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

super();
this.value = void 0;
this.path = void 0;
this.type = void 0;
this.errors = void 0;
this.params = void 0;
this.inner = void 0;
this.name = 'ValidationError';

@@ -25,0 +31,0 @@ this.value = value;

import type { AnyObject, InternalOptions, Callback, Message, Maybe } from './types';
import type Reference from './Reference';
import { Asserts, Config, Defined, NotNull, SetFlag, Thunk, ToggleDefault } from './util/types';
import BaseSchema, { AnySchema, SchemaInnerTypeDescription, SchemaSpec } from './schema';
import Lazy from './Lazy';
import { Defined, Flags, NotNull, SetFlag, Thunk, ToggleDefault, ISchema, UnsetFlag } from './util/types';
import BaseSchema, { SchemaInnerTypeDescription, SchemaSpec } from './schema';
import { ResolveOptions } from './Condition';
export declare type RejectorFn = (value: any, index: number, array: any[]) => boolean;
export declare function create<C extends AnyObject = AnyObject, T extends AnySchema | Lazy<any, any> = AnySchema>(type?: T): ArraySchema<T, Config<C, "">, Asserts<T>[] | undefined>;
export declare function create<C extends AnyObject = AnyObject, T = any>(type?: ISchema<T, C>): ArraySchema<T, C, undefined, "", T[] | undefined>;
export declare namespace create {
var prototype: ArraySchema<any, any, any>;
var prototype: ArraySchema<any, any, any, any, any>;
}
export default class ArraySchema<T extends AnySchema | Lazy<any, any>, C extends Config<any, any> = Config, TIn extends Maybe<Asserts<T>[]> = Asserts<T>[] | undefined> extends BaseSchema<TIn, C> {
innerType?: T;
constructor(type?: T);
export default class ArraySchema<T, TContext, TDefault = undefined, TFlags extends Flags = '', TIn extends any[] | null | undefined = T[] | undefined> extends BaseSchema<TIn, TContext, TDefault, TFlags> {
innerType?: ISchema<T, TContext>;
constructor(type?: ISchema<T, TContext>);
protected _typeCheck(v: any): v is NonNullable<TIn>;
private get _subType();
protected _cast(_value: any, _opts: InternalOptions<C>): any;
protected _validate(_value: any, options: InternalOptions<C> | undefined, callback: Callback): void;
protected _cast(_value: any, _opts: InternalOptions<TContext>): any;
protected _validate(_value: any, options: InternalOptions<TContext> | undefined, callback: Callback): void;
clone(spec?: SchemaSpec<any>): this;
concat<TOther extends ArraySchema<any, any, any>>(schema: TOther): TOther;
concat(schema: any): any;
of<TInner extends AnySchema>(schema: TInner): ArraySchema<TInner>;
of<U>(schema: ISchema<U, TContext>): ArraySchema<U, TContext, TFlags>;
length(length: number | Reference<number>, message?: Message<{

@@ -32,14 +31,18 @@ length: number;

}>): this;
ensure(): ArraySchema<T, SetFlag<C, 'd'>, NonNullable<TIn>>;
ensure(): ArraySchema<T, TContext, TIn, ToggleDefault<TFlags, TIn>, TIn>;
compact(rejector?: RejectorFn): this;
describe(options?: ResolveOptions<C['context']>): SchemaInnerTypeDescription;
describe(options?: ResolveOptions<TContext>): SchemaInnerTypeDescription;
}
export default interface ArraySchema<T extends AnySchema | Lazy<any, any>, C extends Config<any, any> = Config, TIn extends Maybe<Asserts<T>[]> = Asserts<T>[] | undefined> extends BaseSchema<TIn, C> {
default<D extends Maybe<TIn>>(def: Thunk<D>): ArraySchema<T, ToggleDefault<C, D>, TIn>;
defined(msg?: Message): ArraySchema<T, C, Defined<TIn>>;
optional(): ArraySchema<T, C, TIn | undefined>;
required(msg?: Message): ArraySchema<T, C, NonNullable<TIn>>;
notRequired(): ArraySchema<T, C, Maybe<TIn>>;
nullable(isNullable?: true): ArraySchema<T, C, TIn | null>;
nullable(isNullable: false): ArraySchema<T, C, NotNull<TIn>>;
export default interface ArraySchema<T, TContext, TDefault = undefined, TFlags extends Flags = '', TIn extends any[] | null | undefined = T[] | undefined> extends BaseSchema<TIn, TContext, TDefault, TFlags> {
default<D extends Maybe<TIn>>(def: Thunk<D>): ArraySchema<T, TContext, D, ToggleDefault<TFlags, D>, TIn>;
concat<IT, IC, ID, IF extends Flags, IIn extends Maybe<IT[]>>(schema: ArraySchema<IT, IC, ID, IF, IIn>): ArraySchema<NonNullable<T> | IT, TContext & IC, Extract<IF, 'd'> extends never ? TDefault : ID, TFlags | IF, IIn>;
concat(schema: this): this;
defined(msg?: Message): ArraySchema<T, TContext, TDefault, TFlags, Defined<TIn>>;
optional(): ArraySchema<T, TContext, TDefault, TFlags, TIn | undefined>;
required(msg?: Message): ArraySchema<T, TContext, TDefault, TFlags, NonNullable<TIn>>;
notRequired(): ArraySchema<T, TContext, TDefault, TFlags, Maybe<TIn>>;
nullable(msg?: Message): ArraySchema<T, TContext, TDefault, TFlags, TIn | null>;
nonNullable(): ArraySchema<T, TContext, TDefault, TFlags, NotNull<TIn>>;
strip(enabled: false): ArraySchema<T, TContext, TDefault, UnsetFlag<TFlags, 's'>>;
strip(enabled?: true): ArraySchema<T, TContext, TDefault, SetFlag<TFlags, 's'>>;
}

@@ -38,2 +38,3 @@ "use strict";

this.innerType = void 0;
this.innerType = type;

@@ -207,4 +208,5 @@ this.withMutation(() => {

});
}
} // ArraySchema<T, TContext, T[], SetFlag<TFlags, 'd'>, NonNullable<TIn>>
ensure() {

@@ -247,4 +249,2 @@ return this.default(() => []).transform((val, original) => {

exports.default = ArraySchema;
create.prototype = ArraySchema.prototype; //
// Interfaces
//
create.prototype = ArraySchema.prototype;
import BaseSchema from './schema';
import type { AnyObject, Maybe, Message } from './types';
import type { Config, Defined, NotNull, Thunk, ToggleDefault } from './util/types';
import type { Defined, Flags, NotNull, SetFlag, Thunk, ToggleDefault } from './util/types';
export declare function create(): BooleanSchema;
export declare function create<T extends boolean, TContext = AnyObject>(): BooleanSchema<T | undefined, TContext>;
export declare namespace create {
var prototype: BooleanSchema<any, any>;
var prototype: BooleanSchema<any, any, any, any>;
}
export declare function create<T extends boolean, TContext = AnyObject>(): BooleanSchema<T | undefined, Config<TContext>>;
export declare namespace create {
var prototype: BooleanSchema<any, any>;
}
export default class BooleanSchema<TType extends Maybe<boolean> = boolean | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
export default class BooleanSchema<TType extends Maybe<boolean> = boolean | undefined, TContext = AnyObject, TDefault = undefined, TFlags extends Flags = ''> extends BaseSchema<TType, TContext, TDefault, TFlags> {
constructor();
protected _typeCheck(v: any): v is NonNullable<TType>;
isTrue(message?: string | Record<string | number | symbol, unknown> | ((params: any) => unknown) | undefined): BooleanSchema<TType | true, TConfig>;
isFalse(message?: string | Record<string | number | symbol, unknown> | ((params: any) => unknown) | undefined): BooleanSchema<TType | false, TConfig>;
isTrue(message?: Message<any> | undefined): BooleanSchema<TType | true, TContext, TFlags>;
isFalse(message?: Message<any> | undefined): BooleanSchema<TType | false, TContext, TFlags>;
default<D extends Maybe<TType>>(def: Thunk<D>): BooleanSchema<TType, TContext, D, ToggleDefault<TFlags, D>>;
defined(msg?: Message): BooleanSchema<Defined<TType>, TContext, TDefault, TFlags>;
optional(): BooleanSchema<TType | undefined, TContext, TDefault, TFlags>;
required(msg?: Message): BooleanSchema<NonNullable<TType>, TContext, TDefault, TFlags>;
notRequired(): BooleanSchema<Maybe<TType>, TContext, TDefault, TFlags>;
nullable(): BooleanSchema<TType | null, TContext, TDefault, TFlags>;
nonNullable(msg?: Message): BooleanSchema<NotNull<TType>, TContext, TDefault, TFlags>;
strip(): BooleanSchema<TType, TContext, TDefault, SetFlag<TFlags, 's'>>;
}
export default interface BooleanSchema<TType extends Maybe<boolean>, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
default<D extends Maybe<TType>>(def: Thunk<D>): BooleanSchema<TType, ToggleDefault<TConfig, D>>;
concat<TOther extends BooleanSchema<any, any>>(schema: TOther): TOther;
defined(msg?: Message): BooleanSchema<Defined<TType>, TConfig>;
optional(): BooleanSchema<TType | undefined, TConfig>;
required(msg?: Message): BooleanSchema<NonNullable<TType>, TConfig>;
notRequired(): BooleanSchema<Maybe<TType>, TConfig>;
nullable(msg?: Message): BooleanSchema<TType | null, TConfig>;
nonNullable(): BooleanSchema<NotNull<TType>, TConfig>;
}

@@ -75,2 +75,35 @@ "use strict";

default(def) {
return super.default(def);
} // concat<TOther extends BooleanSchema<any, any>>(schema: TOther): TOther;
defined(msg) {
return super.defined(msg);
}
optional() {
return super.defined();
}
required(msg) {
return super.required(msg);
}
notRequired() {
return super.notRequired();
}
nullable() {
return super.nullable();
}
nonNullable(msg) {
return super.nonNullable(msg);
}
strip() {
return super.strip();
}
}

@@ -77,0 +110,0 @@

import Reference from './Reference';
import { SchemaLike } from './types';
export interface ConditionBuilder<T extends SchemaLike> {
(this: T, value: any, schema: T): SchemaLike;
(v1: any, v2: any, schema: T): SchemaLike;
(v1: any, v2: any, v3: any, schema: T): SchemaLike;
(v1: any, v2: any, v3: any, v4: any, schema: T): SchemaLike;
import type { ISchema } from './util/types';
export interface ConditionBuilder<T extends ISchema<any, any>> {
(this: T, value: any, schema: T): ISchema<any, any> | void;
(v1: any, v2: any, schema: T): ISchema<any, any> | void;
(v1: any, v2: any, v3: any, schema: T): ISchema<any, any> | void;
(v1: any, v2: any, v3: any, v4: any, schema: T): ISchema<any, any> | void;
}
export declare type ConditionConfig<T extends SchemaLike> = {
export declare type ConditionConfig<T extends ISchema<any>> = {
is: any | ((...values: any[]) => boolean);
then?: SchemaLike | ((schema: T) => SchemaLike);
otherwise?: SchemaLike | ((schema: T) => SchemaLike);
then?: (schema: T) => ISchema<any>;
otherwise?: (schema: T) => ISchema<any>;
};
export declare type ConditionOptions<T extends SchemaLike> = ConditionBuilder<T> | ConditionConfig<T>;
export declare type ConditionOptions<T extends ISchema<any, any>> = ConditionBuilder<T> | ConditionConfig<T>;
export declare type ResolveOptions<TContext = any> = {

@@ -20,8 +20,8 @@ value?: any;

};
declare class Condition<T extends SchemaLike = SchemaLike> {
declare class Condition<T extends ISchema<any, any> = ISchema<any, any>> {
refs: Reference[];
fn: ConditionBuilder<T>;
constructor(refs: Reference[], options: ConditionOptions<T>);
resolve(base: T, options: ResolveOptions): any;
resolve(base: T, options: ResolveOptions): ISchema<any, import("./types").AnyObject, any, any> | T;
}
export default Condition;

@@ -14,2 +14,3 @@ "use strict";

constructor(refs, options) {
this.fn = void 0;
this.refs = refs;

@@ -33,8 +34,9 @@ this.refs = refs;

this.fn = function (...args) {
let options = args.pop();
var _branch;
let _opts = args.pop();
let schema = args.pop();
let branch = check(...args) ? then : otherwise;
if (!branch) return undefined;
if (typeof branch === 'function') return branch(schema);
return schema.concat(branch.resolve(options));
return (_branch = branch == null ? void 0 : branch(schema)) != null ? _branch : schema;
};

@@ -44,3 +46,4 @@ }

resolve(base, options) {
let values = this.refs.map(ref => ref.getValue(options == null ? void 0 : options.value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context));
let values = this.refs.map(ref => // TODO: ? operator here?
ref.getValue(options == null ? void 0 : options.value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context));
let schema = this.fn.apply(base, values.concat(base, options));

@@ -47,0 +50,0 @@ if (schema === undefined || schema === base) return base;

import Ref from './Reference';
import type { AnyObject, Maybe, Message } from './types';
import type { Config, Defined, NotNull, Thunk, ToggleDefault } from './util/types';
import type { Defined, Flags, NotNull, SetFlag, Thunk, ToggleDefault, UnsetFlag } from './util/types';
import BaseSchema from './schema';
export declare function create(): DateSchema;
export declare function create<T extends Date, TContext = AnyObject>(): DateSchema<T | undefined, TContext>;
export declare namespace create {
var prototype: DateSchema<any, any>;
var prototype: DateSchema<any, any, any, any>;
var INVALID_DATE: Date;
}
export declare function create<T extends Date, TContext = AnyObject>(): DateSchema<T | undefined, Config<TContext>>;
export declare namespace create {
var prototype: DateSchema<any, any>;
var INVALID_DATE: Date;
}
export default class DateSchema<TType extends Maybe<Date> = Date | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
export default class DateSchema<TType extends Maybe<Date> = Date | undefined, TContext = AnyObject, TDefault = undefined, TFlags extends Flags = ''> extends BaseSchema<TType, TContext, TDefault, TFlags> {
static INVALID_DATE: Date;

@@ -27,11 +23,13 @@ constructor();

}
export default interface DateSchema<TType extends Maybe<Date>, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
default<D extends Maybe<TType>>(def: Thunk<D>): DateSchema<TType, ToggleDefault<TConfig, D>>;
export default interface DateSchema<TType extends Maybe<Date>, TContext = AnyObject, TDefault = undefined, TFlags extends Flags = ''> extends BaseSchema<TType, TContext, TDefault, TFlags> {
default<D extends Maybe<TType>>(def: Thunk<D>): DateSchema<TType, TContext, D, ToggleDefault<TFlags, D>>;
concat<TOther extends DateSchema<any, any>>(schema: TOther): TOther;
defined(msg?: Message): DateSchema<Defined<TType>, TConfig>;
optional(): DateSchema<TType | undefined, TConfig>;
required(msg?: Message): DateSchema<NonNullable<TType>, TConfig>;
notRequired(): DateSchema<Maybe<TType>, TConfig>;
nullable(msg?: Message): DateSchema<TType | null, TConfig>;
nonNullable(): DateSchema<NotNull<TType>, TConfig>;
defined(msg?: Message): DateSchema<Defined<TType>, TContext, TDefault, TFlags>;
optional(): DateSchema<TType | undefined, TContext, TDefault, TFlags>;
required(msg?: Message): DateSchema<NonNullable<TType>, TContext, TDefault, TFlags>;
notRequired(): DateSchema<Maybe<TType>, TContext, TDefault, TFlags>;
nullable(msg?: Message): DateSchema<TType | null, TContext, TDefault, TFlags>;
nonNullable(): DateSchema<NotNull<TType>, TContext, TDefault, TFlags>;
strip(enabled: false): DateSchema<TType, TContext, TDefault, UnsetFlag<TFlags, 's'>>;
strip(enabled?: true): DateSchema<TType, TContext, TDefault, SetFlag<TFlags, 's'>>;
}

@@ -1,2 +0,2 @@

import MixedSchema, { create as mixedCreate } from './mixed';
import Mixed, { create as mixedCreate, MixedSchema } from './mixed';
import BooleanSchema, { create as boolCreate } from './boolean';

@@ -15,13 +15,9 @@ import StringSchema, { create as stringCreate } from './string';

import BaseSchema, { AnySchema } from './schema';
import type { TypeOf, Asserts, Config } from './util/types';
import type { InferType } from './util/types';
declare function addMethod<T extends AnySchema>(schemaType: (...arg: any[]) => T, name: string, fn: (this: T, ...args: any[]) => T): void;
declare function addMethod<T extends new (...args: any) => AnySchema>(schemaType: T, name: string, fn: (this: InstanceType<T>, ...args: any[]) => InstanceType<T>): void;
declare type ObjectSchemaOf<T extends AnyObject> = ObjectSchema<{
[k in keyof T]-?: T[k] extends Array<infer E> ? ArraySchema<SchemaOf<E>> : T[k] extends AnyObject ? ObjectSchemaOf<T[k]> : BaseSchema<T[k], Config>;
}>;
declare type SchemaOf<T> = T extends Array<infer E> ? ArraySchema<SchemaOf<E>> : T extends AnyObject ? ObjectSchemaOf<T> : BaseSchema<T, Config>;
export declare type AnyObjectSchema = ObjectSchema<any, any, any>;
export type { SchemaOf, TypeOf, Asserts, Asserts as InferType, AnySchema };
export declare type AnyObjectSchema = ObjectSchema<any, any, any, any>;
export type { AnyObject, InferType, InferType as Asserts, AnySchema };
export { mixedCreate as mixed, boolCreate as bool, boolCreate as boolean, stringCreate as string, numberCreate as number, dateCreate as date, objectCreate as object, arrayCreate as array, refCreate as ref, lazyCreate as lazy, reach, isSchema, addMethod, setLocale, ValidationError, };
export { BaseSchema, MixedSchema, BooleanSchema, StringSchema, NumberSchema, DateSchema, ObjectSchema, ArraySchema, };
export { BaseSchema, Mixed as MixedSchema, MixedSchema as MixedSchemaClass, BooleanSchema, StringSchema, NumberSchema, DateSchema, ObjectSchema, ArraySchema, };
export type { CreateErrorOptions, TestContext, TestFunction, TestOptions, TestConfig, } from './util/createValidation';

@@ -6,13 +6,12 @@ "use strict";

});
exports.addMethod = addMethod;
Object.defineProperty(exports, "MixedSchema", {
Object.defineProperty(exports, "ArraySchema", {
enumerable: true,
get: function () {
return _mixed.default;
return _array.default;
}
});
Object.defineProperty(exports, "mixed", {
Object.defineProperty(exports, "BaseSchema", {
enumerable: true,
get: function () {
return _mixed.create;
return _schema.default;
}

@@ -26,26 +25,20 @@ });

});
Object.defineProperty(exports, "bool", {
Object.defineProperty(exports, "DateSchema", {
enumerable: true,
get: function () {
return _boolean.create;
return _date.default;
}
});
Object.defineProperty(exports, "boolean", {
Object.defineProperty(exports, "MixedSchema", {
enumerable: true,
get: function () {
return _boolean.create;
return _mixed.default;
}
});
Object.defineProperty(exports, "StringSchema", {
Object.defineProperty(exports, "MixedSchemaClass", {
enumerable: true,
get: function () {
return _string.default;
return _mixed.MixedSchema;
}
});
Object.defineProperty(exports, "string", {
enumerable: true,
get: function () {
return _string.create;
}
});
Object.defineProperty(exports, "NumberSchema", {

@@ -57,48 +50,49 @@ enumerable: true,

});
Object.defineProperty(exports, "number", {
Object.defineProperty(exports, "ObjectSchema", {
enumerable: true,
get: function () {
return _number.create;
return _object.default;
}
});
Object.defineProperty(exports, "DateSchema", {
Object.defineProperty(exports, "StringSchema", {
enumerable: true,
get: function () {
return _date.default;
return _string.default;
}
});
Object.defineProperty(exports, "date", {
Object.defineProperty(exports, "ValidationError", {
enumerable: true,
get: function () {
return _date.create;
return _ValidationError.default;
}
});
Object.defineProperty(exports, "ObjectSchema", {
exports.addMethod = addMethod;
Object.defineProperty(exports, "array", {
enumerable: true,
get: function () {
return _object.default;
return _array.create;
}
});
Object.defineProperty(exports, "object", {
Object.defineProperty(exports, "bool", {
enumerable: true,
get: function () {
return _object.create;
return _boolean.create;
}
});
Object.defineProperty(exports, "ArraySchema", {
Object.defineProperty(exports, "boolean", {
enumerable: true,
get: function () {
return _array.default;
return _boolean.create;
}
});
Object.defineProperty(exports, "array", {
Object.defineProperty(exports, "date", {
enumerable: true,
get: function () {
return _array.create;
return _date.create;
}
});
Object.defineProperty(exports, "ref", {
Object.defineProperty(exports, "isSchema", {
enumerable: true,
get: function () {
return _Reference.create;
return _isSchema.default;
}

@@ -112,8 +106,20 @@ });

});
Object.defineProperty(exports, "ValidationError", {
Object.defineProperty(exports, "mixed", {
enumerable: true,
get: function () {
return _ValidationError.default;
return _mixed.create;
}
});
Object.defineProperty(exports, "number", {
enumerable: true,
get: function () {
return _number.create;
}
});
Object.defineProperty(exports, "object", {
enumerable: true,
get: function () {
return _object.create;
}
});
Object.defineProperty(exports, "reach", {

@@ -125,6 +131,6 @@ enumerable: true,

});
Object.defineProperty(exports, "isSchema", {
Object.defineProperty(exports, "ref", {
enumerable: true,
get: function () {
return _isSchema.default;
return _Reference.create;
}

@@ -138,6 +144,6 @@ });

});
Object.defineProperty(exports, "BaseSchema", {
Object.defineProperty(exports, "string", {
enumerable: true,
get: function () {
return _schema.default;
return _string.create;
}

@@ -176,5 +182,5 @@ });

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

@@ -181,0 +187,0 @@ function addMethod(schemaType, name, fn) {

@@ -1,34 +0,35 @@

import type { Callback, ValidateOptions } from './types';
import type { AnyObject, Callback, ValidateOptions } from './types';
import type { ResolveOptions } from './Condition';
import type { AnySchema, CastOptions, ConfigOf, SchemaFieldDescription, SchemaLazyDescription } from './schema';
import { Config, TypedSchema, TypeOf } from './util/types';
export declare type LazyBuilder<T extends AnySchema = any> = (value: any, options: ResolveOptions) => T;
export declare function create<T extends AnySchema>(builder: LazyBuilder<T>): Lazy<T, ConfigOf<T>>;
export declare type LazyReturnValue<T> = T extends Lazy<infer TSchema> ? TSchema : never;
export declare type LazyType<T> = LazyReturnValue<T> extends TypedSchema ? TypeOf<LazyReturnValue<T>> : never;
import type { CastOptions, SchemaFieldDescription, SchemaLazyDescription } from './schema';
import { Flags, ISchema } from './util/types';
import { BaseSchema } from '.';
export declare type LazyBuilder<T, TContext = AnyObject, TDefault = any, TFlags extends Flags = any> = (value: any, options: ResolveOptions) => ISchema<T, TContext, TFlags, TDefault>;
export declare function create<T, TContext = AnyObject, TFlags extends Flags = any, TDefault = any>(builder: LazyBuilder<T, TContext, TDefault, TFlags>): Lazy<T, TContext, TDefault, TFlags>;
export interface LazySpec {
meta: Record<string, unknown> | undefined;
}
declare class Lazy<T extends AnySchema, TConfig extends Config = ConfigOf<T>> implements TypedSchema {
declare class Lazy<T, TContext = AnyObject, TDefault = any, TFlags extends Flags = any> implements ISchema<T, TContext, TFlags, TDefault> {
private builder;
type: "lazy";
__isYupSchema__: boolean;
readonly __type: T['__type'];
readonly __outputType: T['__outputType'];
readonly __outputType: T;
readonly __context: TContext;
readonly __flags: TFlags;
readonly __default: TDefault;
spec: LazySpec;
constructor(builder: LazyBuilder<T>);
clone(): Lazy<T, TConfig>;
constructor(builder: LazyBuilder<T, TContext, TDefault, TFlags>);
clone(): Lazy<T, TContext, TDefault, TFlags>;
private _resolve;
resolve(options: ResolveOptions<TConfig['context']>): T;
cast(value: any, options?: CastOptions<TConfig['context']>): T['__type'];
validate(value: any, options?: ValidateOptions, maybeCb?: Callback): T['__outputType'];
validateSync(value: any, options?: ValidateOptions<TConfig['context']>): T['__outputType'];
validateAt(path: string, value: any, options?: ValidateOptions<TConfig['context']>): Promise<any>;
validateSyncAt(path: string, value: any, options?: ValidateOptions<TConfig['context']>): any;
isValid(value: any, options?: ValidateOptions<TConfig['context']>): Promise<boolean>;
isValidSync(value: any, options?: ValidateOptions<TConfig['context']>): boolean;
describe(options?: ResolveOptions<TConfig['context']>): SchemaLazyDescription | SchemaFieldDescription;
resolve(options: ResolveOptions<TContext>): BaseSchema<T, TContext, TDefault, TFlags>;
cast(value: any, options?: CastOptions<TContext>): T;
validate(value: any, options?: ValidateOptions, maybeCb?: Callback): Promise<T>;
validateSync(value: any, options?: ValidateOptions<TContext>): T;
validateAt(path: string, value: any, options?: ValidateOptions<TContext>): Promise<any>;
validateSyncAt(path: string, value: any, options?: ValidateOptions<TContext>): any;
isValid(value: any, options?: ValidateOptions<TContext>): Promise<boolean>;
isValidSync(value: any, options?: ValidateOptions<TContext>): boolean;
describe(options?: ResolveOptions<TContext>): SchemaLazyDescription | SchemaFieldDescription;
meta(): Record<string, unknown> | undefined;
meta(obj: Record<string, unknown>): Lazy<T, TConfig>;
meta(obj: Record<string, unknown>): Lazy<T, TContext, TDefault, TFlags>;
}
export default Lazy;

@@ -23,2 +23,3 @@ "use strict";

this.__isYupSchema__ = true;
this.spec = void 0;

@@ -38,3 +39,3 @@ this._resolve = (value, options = {}) => {

clone() {
const next = new Lazy(this.builder);
const next = create(this.builder);
next.spec = _extends({}, this.spec);

@@ -41,0 +42,0 @@ return next;

@@ -87,2 +87,11 @@ import { Message } from './types';

}
export interface LocaleObject {
mixed?: MixedLocale;
string?: StringLocale;
number?: NumberLocale;
date?: DateLocale;
boolean?: BooleanLocale;
object?: ObjectLocale;
array?: ArrayLocale;
}
export declare let mixed: Required<MixedLocale>;

@@ -89,0 +98,0 @@ export declare let string: Required<StringLocale>;

@@ -6,3 +6,3 @@ "use strict";

});
exports.default = exports.array = exports.object = exports.boolean = exports.date = exports.number = exports.string = exports.mixed = void 0;
exports.string = exports.object = exports.number = exports.mixed = exports.default = exports.date = exports.boolean = exports.array = void 0;

@@ -70,3 +70,3 @@ var _printValue = _interopRequireDefault(require("./util/printValue"));

max: '${path} field must have less than or equal to ${max} items',
length: '${path} must be have ${length} items'
length: '${path} must have ${length} items'
};

@@ -73,0 +73,0 @@ exports.array = array;

@@ -1,21 +0,23 @@

import { Maybe, Message, Optionals } from './types';
import type { Config, Defined, Thunk, ToggleDefault } from './util/types';
import { AnyObject, Maybe, Message, Optionals } from './types';
import type { Defined, Flags, SetFlag, Thunk, ToggleDefault, UnsetFlag } from './util/types';
import BaseSchema from './schema';
export declare class MixedSchema<TType = any, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
default<D extends Maybe<TType>>(def: Thunk<D>): MixedSchema<TType, ToggleDefault<TConfig, D>>;
concat<IT, IC extends Config<any, any>>(schema: MixedSchema<IT, IC>): MixedSchema<NonNullable<TType> | IT, TConfig & IC>;
concat<IT, IC extends Config<any, any>>(schema: BaseSchema<IT, IC>): MixedSchema<NonNullable<TType> | Optionals<IT>, TConfig & IC>;
export declare class MixedSchema<TType = any, TContext = AnyObject, TDefault = undefined, TFlags extends Flags = ''> extends BaseSchema<TType, TContext, TDefault, TFlags> {
default<D extends Maybe<TType>>(def: Thunk<D>): MixedSchema<TType, TContext, D, ToggleDefault<TFlags, D>>;
concat<IT, IC, ID, IF extends Flags>(schema: MixedSchema<IT, IC, ID, IF>): MixedSchema<NonNullable<TType> | IT, TContext & IC, ID, TFlags | IF>;
concat<IT, IC, ID, IF extends Flags>(schema: BaseSchema<IT, IC, ID, IF>): MixedSchema<NonNullable<TType> | Optionals<IT>, TContext & IC, ID, TFlags | IF>;
concat(schema: this): this;
defined(msg?: Message): MixedSchema<Defined<TType>, TConfig>;
optional(): MixedSchema<TType | undefined, TConfig>;
required(msg?: Message): MixedSchema<NonNullable<TType>, TConfig>;
notRequired(): MixedSchema<Maybe<TType>, TConfig>;
nullable(msg?: Message): MixedSchema<TType | null, TConfig>;
nonNullable(): MixedSchema<Exclude<TType, null>, TConfig>;
defined(msg?: Message): MixedSchema<Defined<TType>, TContext, TDefault, TFlags>;
optional(): MixedSchema<TType | undefined, TContext, TDefault, TFlags>;
required(msg?: Message): MixedSchema<NonNullable<TType>, TContext, TDefault, TFlags>;
notRequired(): MixedSchema<Maybe<TType>, TContext, TDefault, TFlags>;
nullable(msg?: Message): MixedSchema<TType | null, TContext, TDefault, TFlags>;
nonNullable(): MixedSchema<Exclude<TType, null>, TContext, TDefault, TFlags>;
strip(enabled: false): MixedSchema<TType, TContext, TDefault, UnsetFlag<TFlags, 's'>>;
strip(enabled?: true): MixedSchema<TType, TContext, TDefault, SetFlag<TFlags, 's'>>;
}
declare const Mixed: typeof MixedSchema;
export default Mixed;
export declare function create<TType = any>(): MixedSchema<TType | undefined, Config<Record<string, any>, "">>;
export declare function create<TType = any>(): MixedSchema<TType | undefined, AnyObject, undefined, "">;
export declare namespace create {
var prototype: MixedSchema<any, any>;
var prototype: MixedSchema<any, any, any, any>;
}
import type { AnyObject, Maybe, Message } from './types';
import type Reference from './Reference';
import type { AnyConfig, Config, Defined, MergeConfig, NotNull, SetFlag, Thunk, ToggleDefault } from './util/types';
import type { Concat, Defined, Flags, NotNull, SetFlag, Thunk, ToggleDefault, UnsetFlag } from './util/types';
import BaseSchema from './schema';
export declare function create(): NumberSchema;
export declare function create<T extends number, TContext = AnyObject>(): NumberSchema<T | undefined, TContext>;
export declare namespace create {
var prototype: NumberSchema<any, any>;
var prototype: NumberSchema<any, any, any, any>;
}
export declare function create<T extends number, TContext = AnyObject>(): NumberSchema<T | undefined, Config<TContext>>;
export declare namespace create {
var prototype: NumberSchema<any, any>;
}
export default class NumberSchema<TType extends Maybe<number> = number | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
export default class NumberSchema<TType extends Maybe<number> = number | undefined, TContext = AnyObject, TDefault = undefined, TFlags extends Flags = ''> extends BaseSchema<TType, TContext, TDefault, TFlags> {
constructor();

@@ -36,15 +33,16 @@ protected _typeCheck(value: any): value is NonNullable<TType>;

truncate(): this;
round(method: 'ceil' | 'floor' | 'round' | 'trunc'): this;
round(method?: 'ceil' | 'floor' | 'round' | 'trunc'): this;
}
export default interface NumberSchema<TType extends Maybe<number> = number | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
strip(): NumberSchema<TType, SetFlag<TConfig, 's'>>;
default<D extends Maybe<TType>>(def: Thunk<D>): NumberSchema<TType, ToggleDefault<TConfig, D>>;
concat<T extends Maybe<number>, C extends AnyConfig>(schema: NumberSchema<T, C>): NumberSchema<NonNullable<TType> | T, MergeConfig<TConfig, C>>;
export default interface NumberSchema<TType extends Maybe<number> = number | undefined, TContext = AnyObject, TDefault = undefined, TFlags extends Flags = ''> extends BaseSchema<TType, TContext, TDefault, TFlags> {
default<D extends Maybe<TType>>(def: Thunk<D>): NumberSchema<TType, TContext, D, ToggleDefault<TFlags, D>>;
concat<UType extends Maybe<number>, UContext, UFlags extends Flags, UDefault>(schema: NumberSchema<UType, UContext, UDefault, UFlags>): NumberSchema<Concat<TType, UType>, TContext & UContext, UDefault, TFlags | UFlags>;
concat(schema: this): this;
defined(msg?: Message): NumberSchema<Defined<TType>, TConfig>;
optional(): NumberSchema<TType | undefined, TConfig>;
required(msg?: Message): NumberSchema<NonNullable<TType>, TConfig>;
notRequired(): NumberSchema<Maybe<TType>, TConfig>;
nullable(msg?: Message): NumberSchema<TType | null, TConfig>;
nonNullable(): NumberSchema<NotNull<TType>, TConfig>;
defined(msg?: Message): NumberSchema<Defined<TType>, TContext, TDefault, TFlags>;
optional(): NumberSchema<TType | undefined, TContext, TDefault, TFlags>;
required(msg?: Message): NumberSchema<NonNullable<TType>, TContext, TDefault, TFlags>;
notRequired(): NumberSchema<Maybe<TType>, TContext, TDefault, TFlags>;
nullable(msg?: Message): NumberSchema<TType | null, TContext, TDefault, TFlags>;
nonNullable(): NumberSchema<NotNull<TType>, TContext, TDefault, TFlags>;
strip(enabled: false): NumberSchema<TType, TContext, TDefault, UnsetFlag<TFlags, 's'>>;
strip(enabled?: true): NumberSchema<TType, TContext, TDefault, SetFlag<TFlags, 's'>>;
}

@@ -1,37 +0,33 @@

import { InternalOptions, Callback, Maybe, Optionals, Preserve, Message } from './types';
import type { TypedSchema, Defined, Thunk, Config, NotNull, ToggleDefault, _, MakePartial } from './util/types';
import { Flags, ISchema, SetFlag, ToggleDefault, UnsetFlag } from './util/types';
import { InternalOptions, Callback, Maybe, Message } from './types';
import type { Defined, Thunk, NotNull, _ } from './util/types';
import type Reference from './Reference';
import Lazy from './Lazy';
import BaseSchema, { AnySchema, SchemaObjectDescription, SchemaSpec } from './schema';
import BaseSchema, { SchemaObjectDescription, SchemaSpec } from './schema';
import { ResolveOptions } from './Condition';
export declare type Assign<T extends {}, U extends {}> = {
[P in keyof T]: P extends keyof U ? U[P] : T[P];
} & U;
export declare type AnyObject = Record<string, any>;
export declare type ObjectShape = Record<string, AnySchema | Reference | Lazy<any, any>>;
declare type FieldType<T extends AnySchema | Reference | Lazy<any, any>, F extends '__type' | '__outputType'> = T extends TypedSchema ? T[F] : T extends Reference ? unknown : never;
export declare type DefaultFromShape<Shape extends ObjectShape> = {
[K in keyof Shape]: Shape[K] extends ObjectSchema<infer TShape> ? DefaultFromShape<TShape> : Shape[K] extends {
getDefault: () => infer D;
} ? Preserve<D, undefined> extends never ? Defined<D> : Preserve<D, undefined> : undefined;
import type { AnyObject, DefaultFromShape, MakePartial, ObjectShape, PartialDeep, TypeFromShape } from './util/objectTypes';
export type { AnyObject };
declare type MakeKeysOptional<T> = T extends AnyObject ? _<MakePartial<T>> : T;
export declare type Shape<T extends Maybe<AnyObject>, C = AnyObject> = {
[field in keyof T]: ISchema<T[field], C> | Reference;
};
export declare type TypeOfShape<Shape extends ObjectShape> = {
[K in keyof Shape]: FieldType<Shape[K], '__type'>;
};
export declare type AssertsShape<S extends ObjectShape> = MakePartial<{
[K in keyof S]: FieldType<S[K], '__outputType'>;
}> & {
[k: string]: any;
};
export declare type PartialSchema<S extends ObjectShape> = {
[K in keyof S]: S[K] extends BaseSchema ? ReturnType<S[K]['optional']> : S[K];
};
export declare type DeepPartialSchema<S extends ObjectShape> = {
[K in keyof S]: S[K] extends ObjectSchema<any, any, any> ? ReturnType<S[K]['deepPartial']> : S[K] extends BaseSchema ? ReturnType<S[K]['optional']> : S[K];
};
export declare type ObjectSchemaSpec = SchemaSpec<any> & {
noUnknown?: boolean;
};
export default class ObjectSchema<TShape extends ObjectShape, TConfig extends Config<any, any> = Config<AnyObject, 'd'>, TIn extends Maybe<AssertsShape<TShape>> = AssertsShape<TShape> | undefined> extends BaseSchema<TIn, TConfig> {
fields: TShape;
export declare function create<C = AnyObject, S extends ObjectShape = {}>(spec?: S): ObjectSchema<_<TypeFromShape<S, C>>, C, _<DefaultFromShape<S>>, "d">;
export declare namespace create {
var prototype: ObjectSchema<any, any, any, any>;
}
export default interface ObjectSchema<TIn extends Maybe<AnyObject>, TContext = AnyObject, TDefault = any, TFlags extends Flags = 'd'> extends BaseSchema<MakeKeysOptional<TIn>, TContext, TDefault, TFlags> {
default<D extends Maybe<AnyObject>>(def: Thunk<D>): ObjectSchema<TIn, TContext, D, ToggleDefault<TFlags, 'd'>>;
defined(msg?: Message): ObjectSchema<Defined<TIn>, TContext, TDefault, TFlags>;
optional(): ObjectSchema<TIn | undefined, TContext, TDefault, TFlags>;
required(msg?: Message): ObjectSchema<NonNullable<TIn>, TContext, TDefault, TFlags>;
notRequired(): ObjectSchema<Maybe<TIn>, TContext, TDefault, TFlags>;
nullable(msg?: Message): ObjectSchema<TIn | null, TContext, TDefault, TFlags>;
nonNullable(): ObjectSchema<NotNull<TIn>, TContext, TDefault, TFlags>;
strip(enabled: false): ObjectSchema<TIn, TContext, TDefault, UnsetFlag<TFlags, 's'>>;
strip(enabled?: true): ObjectSchema<TIn, TContext, TDefault, SetFlag<TFlags, 's'>>;
}
export default class ObjectSchema<TIn extends Maybe<AnyObject>, TContext = AnyObject, TDefault = any, TFlags extends Flags = 'd'> extends BaseSchema<MakeKeysOptional<TIn>, TContext, TDefault, TFlags> {
fields: Shape<NonNullable<TIn>, TContext>;
spec: ObjectSchemaSpec;

@@ -41,19 +37,19 @@ private _sortErrors;

private _excludedEdges;
constructor(spec?: TShape);
protected _typeCheck(value: any): value is NonNullable<TIn>;
protected _cast(_value: any, options?: InternalOptions<TConfig['context']>): any;
protected _validate(_value: any, opts: InternalOptions<TConfig["context"]> | undefined, callback: Callback): void;
constructor(spec?: Shape<TIn, TContext>);
protected _typeCheck(value: any): value is NonNullable<MakeKeysOptional<TIn>>;
protected _cast(_value: any, options?: InternalOptions<TContext>): any;
protected _validate(_value: any, opts: InternalOptions<TContext> | undefined, callback: Callback): void;
clone(spec?: ObjectSchemaSpec): this;
concat<TOther extends ObjectSchema<any, any, any>>(schema: TOther): TOther extends ObjectSchema<infer S, infer C, infer IType> ? ObjectSchema<TShape & S, TConfig & C, AssertsShape<TShape & S> | Optionals<IType>> : never;
concat<IIn, IC, ID, IF extends Flags>(schema: ObjectSchema<IIn, IC, ID, IF>): ObjectSchema<NonNullable<TIn> | IIn, TContext & IC, TDefault & ID, TFlags | IF>;
concat(schema: this): this;
protected _getDefault(): any;
getDefaultFromShape(): _<DefaultFromShape<TShape>>;
private setFields;
shape<TNextShape extends ObjectShape>(additions: TNextShape, excludes?: [string, string][]): ObjectSchema<Assign<TShape, TNextShape>, TConfig, Extract<TIn, null | undefined> | AssertsShape<Assign<TShape, TNextShape>>>;
partial(): ObjectSchema<PartialSchema<TShape>, TConfig, Extract<TIn, null | undefined> | AssertsShape<PartialSchema<TShape>>>;
deepPartial(): ObjectSchema<DeepPartialSchema<TShape>, TConfig, Optionals<TIn> | undefined | AssertsShape<DeepPartialSchema<TShape>>>;
pick<TKey extends keyof TShape>(keys: TKey[]): ObjectSchema<Pick<TShape, TKey>, TConfig, Extract<TIn, null | undefined> | AssertsShape<Pick<TShape, TKey>>>;
omit<TKey extends keyof TShape>(keys: TKey[]): ObjectSchema<Pick<TShape, Exclude<keyof TShape, TKey>>, TConfig, Extract<TIn, null | undefined> | AssertsShape<Pick<TShape, Exclude<keyof TShape, TKey>>>>;
from(from: string, to: keyof TShape, alias?: boolean): this;
noUnknown(noAllow?: boolean, message?: Message<any>): this;
shape<U extends ObjectShape>(additions: U, excludes?: [string, string][]): ObjectSchema<_<{ [P in keyof TIn]: P extends keyof U ? TypeFromShape<U, TContext>[P] : TIn[P]; } & TypeFromShape<U, TContext>> | _<Extract<TIn, null | undefined>>, TContext, Extract<TFlags, "d"> extends never ? _<TDefault & DefaultFromShape<U>> : TDefault, TFlags>;
partial(): ObjectSchema<Partial<TIn>, TContext, TDefault, TFlags>;
deepPartial(): ObjectSchema<PartialDeep<TIn>, TContext, TDefault, TFlags>;
pick<TKey extends keyof TIn>(keys: TKey[]): ObjectSchema<{ [K in TKey]: TIn[K]; }, TContext, TDefault, TFlags>;
omit<TKey extends keyof TIn>(keys: TKey[]): ObjectSchema<Omit<TIn, TKey>, TContext, TDefault, TFlags>;
from(from: string, to: keyof TIn, alias?: boolean): this;
noUnknown(message?: Message): this;
noUnknown(noAllow: boolean, message?: Message): this;
unknown(allow?: boolean, message?: Message<any>): this;

@@ -64,17 +60,3 @@ transformKeys(fn: (key: string) => string): this;

constantCase(): this;
describe(options?: ResolveOptions<TConfig['context']>): SchemaObjectDescription;
describe(options?: ResolveOptions<TContext>): SchemaObjectDescription;
}
export declare function create<TShape extends ObjectShape = {}>(spec?: TShape): ObjectSchema<TShape, Config<Record<string, any>, "d">, AssertsShape<TShape> | undefined>;
export declare namespace create {
var prototype: ObjectSchema<any, any, any>;
}
export default interface ObjectSchema<TShape extends ObjectShape, TConfig extends Config<any, any> = Config<AnyObject, 'd'>, TIn extends Maybe<AssertsShape<TShape>> = AssertsShape<TShape> | undefined> extends BaseSchema<TIn, TConfig> {
default<D extends Maybe<AnyObject>>(def: Thunk<D>): ObjectSchema<TShape, ToggleDefault<TConfig, D>, TIn>;
defined(msg?: Message): ObjectSchema<TShape, TConfig, Defined<TIn>>;
optional(): ObjectSchema<TShape, TConfig, TIn | undefined>;
required(msg?: Message): ObjectSchema<TShape, TConfig, NonNullable<TIn>>;
notRequired(): ObjectSchema<TShape, TConfig, Maybe<TIn>>;
nullable(isNullable?: true): ObjectSchema<TShape, TConfig, TIn | null>;
nullable(isNullable: false): ObjectSchema<TShape, TConfig, NotNull<TIn>>;
}
export {};

@@ -46,3 +46,8 @@ "use strict";

function create(spec) {
return new ObjectSchema(spec);
}
class ObjectSchema extends _schema.default {
//readonly (keyof TIn & string)[]
constructor(spec) {

@@ -90,5 +95,3 @@ super({

let strip = (_options$stripUnknown = options.stripUnknown) != null ? _options$stripUnknown : this.spec.noUnknown;
let props = this._nodes.concat(Object.keys(value).filter(v => this._nodes.indexOf(v) === -1));
let props = [].concat(this._nodes, Object.keys(value).filter(v => !this._nodes.includes(v)));
let intermediateValue = {}; // is filled during the transform below

@@ -236,3 +239,3 @@

return next.withMutation(s => s.setFields(nextFields));
return next.withMutation(s => s.setFields(nextFields, this._excludedEdges));
}

@@ -250,6 +253,2 @@

return this.getDefaultFromShape();
}
getDefaultFromShape() {
let dft = {};

@@ -259,3 +258,3 @@

const field = this.fields[key];
dft[key] = 'default' in field ? field.getDefault() : undefined;
dft[key] = 'getDefault' in field ? field.getDefault() : undefined;
});

@@ -282,4 +281,3 @@

if (!Array.isArray(excludes[0])) excludes = [excludes];
let keys = excludes.map(([first, second]) => `${first}-${second}`);
edges = edges.concat(keys);
edges = [...next._excludedEdges, ...excludes];
} // XXX: excludes here is wrong

@@ -349,3 +347,3 @@

noUnknown(noAllow = true, message = _locale.object.noUnknown) {
if (typeof noAllow === 'string') {
if (typeof noAllow !== 'boolean') {
message = noAllow;

@@ -427,7 +425,2 @@ noAllow = true;

exports.default = ObjectSchema;
function create(spec) {
return new ObjectSchema(spec);
}
create.prototype = ObjectSchema.prototype;

@@ -5,3 +5,3 @@ import type { SchemaRefDescription } from './schema';

};
export declare function create(key: string, options?: ReferenceOptions): Reference<unknown>;
export declare function create<TValue = unknown>(key: string, options?: ReferenceOptions<TValue>): Reference<TValue>;
export default class Reference<TValue = unknown> {

@@ -8,0 +8,0 @@ readonly key: string;

@@ -22,2 +22,9 @@ "use strict";

constructor(key, options = {}) {
this.key = void 0;
this.isContext = void 0;
this.isValue = void 0;
this.isSibling = void 0;
this.path = void 0;
this.getter = void 0;
this.map = void 0;
if (typeof key !== 'string') throw new TypeError('ref must be a string, got: ' + key);

@@ -24,0 +31,0 @@ this.key = key.trim();

import { ConditionOptions, ResolveOptions } from './Condition';
import { TestFunction, Test, TestConfig } from './util/createValidation';
import { ValidateOptions, TransformFunction, Message, Callback, InternalOptions, Maybe, ExtraParams, Preserve } from './types';
import { ValidateOptions, TransformFunction, Message, Callback, InternalOptions, Maybe, ExtraParams, AnyObject } from './types';
import ReferenceSet from './util/ReferenceSet';
import Reference from './Reference';
import { Config, Defined, Flags, SetFlag, Thunk, _ } from './util/types';
export { Config };
export declare type ConfigOf<T> = T extends AnySchema<any, infer C> ? C : never;
export declare type ContextOf<T> = ConfigOf<T>['context'];
export declare type FlagsOf<T> = T extends AnySchema ? T['__flags'] : never;
export declare type HasFlag<T, F extends Flags> = F extends FlagsOf<T> ? true : never;
export declare type ResolveFlags<T, F extends Flags> = Preserve<F, 'd'> extends never ? T : Defined<T>;
import type { Defined, Flags, ISchema, ResolveFlags, Thunk } from './util/types';
export declare type SchemaSpec<TDefault> = {

@@ -28,3 +22,3 @@ nullable: boolean;

};
export declare type AnySchema<TType = any, C extends Config = any> = BaseSchema<TType, C>;
export declare type AnySchema<TType = any, C = AnyObject, D = any, F extends Flags = Flags> = BaseSchema<TType, C, D, F>;
export interface CastOptions<C = {}> {

@@ -67,8 +61,9 @@ parent?: any;

}
export default abstract class BaseSchema<TType = any, TConfig extends Config<any, any> = Config> {
export default abstract class BaseSchema<TType = any, TContext = AnyObject, TDefault = any, TFlags extends Flags = ''> implements ISchema<TType, TContext, TFlags, TDefault> {
readonly type: string;
readonly __type: TType;
readonly __outputType: ResolveFlags<TType, TConfig['flags']>;
readonly __flags: TConfig['flags'];
readonly __outputType: ResolveFlags<TType, TFlags>;
readonly __context: TContext;
readonly __flags: TFlags;
readonly __isYupSchema__: boolean;
readonly __default: TDefault;
readonly deps: readonly string[];

@@ -95,3 +90,3 @@ tests: Test[];

isType(v: unknown): v is TType;
resolve(options: ResolveOptions): this;
resolve(options: ResolveOptions<TContext>): this;
/**

@@ -104,11 +99,11 @@ *

*/
cast(value: any, options?: CastOptions<TConfig['context']>): _<this['__outputType']>;
protected _cast(rawValue: any, _options: CastOptions<TConfig['context']>): any;
protected _validate(_value: any, options: InternalOptions<TConfig["context"]> | undefined, cb: Callback): void;
validate(value: any, options?: ValidateOptions<TConfig['context']>): Promise<_<this['__outputType']>>;
validateSync(value: any, options?: ValidateOptions<TConfig['context']>): _<this['__outputType']>;
isValid(value: any, options?: ValidateOptions<TConfig['context']>): Promise<boolean>;
isValidSync(value: any, options?: ValidateOptions<TConfig['context']>): value is this['__outputType'];
cast(value: any, options?: CastOptions<TContext>): this['__outputType'];
protected _cast(rawValue: any, _options: CastOptions<TContext>): any;
protected _validate(_value: any, options: InternalOptions<TContext> | undefined, cb: Callback): void;
validate(value: any, options?: ValidateOptions<TContext>): Promise<this['__outputType']>;
validateSync(value: any, options?: ValidateOptions<TContext>): this['__outputType'];
isValid(value: any, options?: ValidateOptions<TContext>): Promise<boolean>;
isValidSync(value: any, options?: ValidateOptions<TContext>): value is this['__outputType'];
protected _getDefault(): any;
getDefault(options?: ResolveOptions): Preserve<TConfig['flags'], 'd'> extends never ? undefined : Defined<TType>;
getDefault(options?: ResolveOptions<TContext>): TDefault;
default(def: Thunk<any>): any;

@@ -139,6 +134,6 @@ strict(isStrict?: boolean): this;

*/
test(options: TestConfig<this['__outputType'], TConfig['context']>): this;
test(test: TestFunction<this['__outputType'], TConfig['context']>): this;
test(name: string, test: TestFunction<this['__outputType'], TConfig['context']>): this;
test(name: string, message: Message, test: TestFunction<this['__outputType'], TConfig['context']>): this;
test(options: TestConfig<this['__outputType'], TContext>): this;
test(test: TestFunction<this['__outputType'], TContext>): this;
test(name: string, test: TestFunction<this['__outputType'], TContext>): this;
test(name: string, message: Message, test: TestFunction<this['__outputType'], TContext>): this;
when(options: ConditionOptions<this>): this;

@@ -153,3 +148,3 @@ when(keys: string | string[], options: ConditionOptions<this>): this;

}>): this;
strip(strip?: boolean): BaseSchema<TType, SetFlag<TConfig, 's'>>;
strip(strip?: boolean): any;
/**

@@ -160,7 +155,7 @@ * Return a serialized description of the schema including validations, flags, types etc.

*/
describe(options?: ResolveOptions<TConfig['context']>): SchemaDescription;
describe(options?: ResolveOptions<TContext>): SchemaDescription;
}
export default interface BaseSchema<TType = any, TConfig extends Config<any, any> = Config> {
validateAt(path: string, value: any, options?: ValidateOptions<TConfig['context']>): Promise<any>;
validateSyncAt(path: string, value: any, options?: ValidateOptions<TConfig['context']>): any;
export default interface BaseSchema<TType = any, TContext = AnyObject, TDefault = any, TFlags extends Flags = ''> {
validateAt(path: string, value: any, options?: ValidateOptions<TContext>): Promise<any>;
validateSyncAt(path: string, value: any, options?: ValidateOptions<TContext>): any;
equals: BaseSchema['oneOf'];

@@ -167,0 +162,0 @@ is: BaseSchema['oneOf'];

@@ -6,8 +6,2 @@ "use strict";

});
Object.defineProperty(exports, "Config", {
enumerable: true,
get: function () {
return _types.Config;
}
});
exports.default = void 0;

@@ -31,4 +25,2 @@

var _toArray = _interopRequireDefault(require("./util/toArray"));
var _ValidationError = _interopRequireDefault(require("./ValidationError"));

@@ -40,3 +32,3 @@

var _types = require("./util/types");
var _toArray = _interopRequireDefault(require("./util/toArray"));

@@ -49,4 +41,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

constructor(options) {
this.type = void 0;
this.deps = [];
this.tests = void 0;
this.transforms = void 0;
this.conditions = [];
this._mutate = void 0;
this.internalTests = {};

@@ -56,2 +52,3 @@ this._whitelist = new _ReferenceSet.default();

this.exclusiveTests = Object.create(null);
this.spec = void 0;
this.tests = [];

@@ -120,11 +117,4 @@ this.transforms = [];

return next;
} // withContext<C extends AnyObject>(): BaseSchema<
// TType,
// C,
// TOut
// > {
// return this as any;
// }
}
withMutation(fn) {

@@ -144,8 +134,4 @@ let before = this._mutate;

const mergedSpec = _extends({}, base.spec, combined.spec); // if (combined.spec.nullable === UNSET)
// mergedSpec.nullable = base.spec.nullable;
// if (combined.spec.presence === UNSET)
// mergedSpec.presence = base.spec.presence;
const mergedSpec = _extends({}, base.spec, combined.spec);
combined.spec = mergedSpec;

@@ -167,2 +153,3 @@ combined.internalTests = _extends({}, base.internalTests, combined.internalTests); // manually merge the blacklist/whitelist (the other `schema` takes

});
combined.transforms = [...base.transforms, ...combined.transforms];
return combined;

@@ -282,3 +269,3 @@ }

});
} // validate<U extends TType>(value: U, options?: ValidateOptions<TConfig['context']>): Promise<U>;
} // validate<U extends TType>(value: U, options?: ValidateOptions<TContext>): Promise<U>;

@@ -294,3 +281,3 @@

}));
} // validateSync<U extends TType>(value: U, options?: ValidateOptions<TConfig['context']>): U;
} // validateSync<U extends TType>(value: U, options?: ValidateOptions<TContext>): U;

@@ -341,3 +328,4 @@

getDefault(options) {
getDefault(options // If schema is defaulted we know it's at least not undefined
) {
let schema = this.resolve(options || {});

@@ -555,5 +543,7 @@ return schema._getDefault();

let valids = this.schema._whitelist;
return valids.has(value, this.resolve) ? true : this.createError({
let resolved = valids.resolveAll(this.resolve);
return resolved.includes(value) ? true : this.createError({
params: {
values: valids.toArray().join(', ')
values: valids.toArray().join(', '),
resolved
}

@@ -580,5 +570,7 @@ });

let invalids = this.schema._blacklist;
if (invalids.has(value, this.resolve)) return this.createError({
let resolved = invalids.resolveAll(this.resolve);
if (resolved.includes(value)) return this.createError({
params: {
values: invalids.toArray().join(', ')
values: invalids.toArray().join(', '),
resolved
}

@@ -591,4 +583,5 @@ });

return next;
}
} //BaseSchema<TType, SetFlag<TFlags, 's'>>
strip(strip = true) {

@@ -595,0 +588,0 @@ let next = this.clone();

import { MixedLocale } from './locale';
import type Reference from './Reference';
import type { Message, Maybe, AnyObject, Optionals } from './types';
import type { AnyConfig, Defined, MergeConfig, NotNull, SetFlag, Thunk, ToggleDefault } from './util/types';
import BaseSchema, { Config } from './schema';
import type { Concat, Defined, Flags, NotNull, SetFlag, Thunk, ToggleDefault, UnsetFlag } from './util/types';
import BaseSchema from './schema';
export declare type MatchOptions = {

@@ -14,11 +14,8 @@ excludeEmptyString?: boolean;

declare function create(): StringSchema;
declare function create<T extends string, TContext = AnyObject>(): StringSchema<T | undefined, TContext>;
declare namespace create {
var prototype: StringSchema<any, any>;
var prototype: StringSchema<any, any, any, any>;
}
declare function create<T extends string, TContext = AnyObject>(): StringSchema<T | undefined, Config<TContext>>;
declare namespace create {
var prototype: StringSchema<any, any>;
}
export { create };
export default class StringSchema<TType extends Maybe<string> = string | undefined, TConfig extends AnyConfig = Config> extends BaseSchema<TType, TConfig> {
export default class StringSchema<TType extends Maybe<string> = string | undefined, TContext = AnyObject, TDefault = undefined, TFlags extends Flags = ''> extends BaseSchema<TType, TContext, TDefault, TFlags> {
constructor();

@@ -51,14 +48,15 @@ protected _typeCheck(value: any): value is NonNullable<TType>;

}
export default interface StringSchema<TType extends Maybe<string> = string | undefined, TConfig extends AnyConfig = Config> extends BaseSchema<TType, TConfig> {
default<D extends Maybe<TType>>(def: Thunk<D>): StringSchema<TType, ToggleDefault<TConfig, D>>;
oneOf<U extends TType>(arrayOfValues: ReadonlyArray<U | Reference>, message?: MixedLocale['oneOf']): StringSchema<U | Optionals<TType>, TConfig>;
concat<T extends Maybe<string>, C extends AnyConfig>(schema: StringSchema<T, C>): StringSchema<NonNullable<TType> | T, MergeConfig<TConfig, C>>;
export default interface StringSchema<TType extends Maybe<string> = string | undefined, TContext = AnyObject, TDefault = undefined, TFlags extends Flags = ''> extends BaseSchema<TType, TContext, TDefault, TFlags> {
default<D extends Maybe<TType>>(def: Thunk<D>): StringSchema<TType, TContext, D, ToggleDefault<TFlags, D>>;
oneOf<U extends TType>(arrayOfValues: ReadonlyArray<U | Reference>, message?: MixedLocale['oneOf']): StringSchema<U | Optionals<TType>, TContext, TDefault, TFlags>;
concat<UType extends Maybe<string>, UContext, UDefault, UFlags extends Flags>(schema: StringSchema<UType, UContext, UDefault, UFlags>): StringSchema<Concat<TType, UType>, TContext & UContext, UDefault, TFlags | UFlags>;
concat(schema: this): this;
defined(msg?: Message): StringSchema<Defined<TType>, TConfig>;
optional(): StringSchema<TType | undefined, TConfig>;
required(msg?: Message): StringSchema<NonNullable<TType>, TConfig>;
notRequired(): StringSchema<Maybe<TType>, TConfig>;
nullable(msg?: Message<any>): StringSchema<TType | null, TConfig>;
nonNullable(): StringSchema<NotNull<TType>, TConfig>;
strip(): StringSchema<TType, SetFlag<TConfig, 's'>>;
defined(msg?: Message): StringSchema<Defined<TType>, TContext, TDefault, TFlags>;
optional(): StringSchema<TType | undefined, TContext, TDefault, TFlags>;
required(msg?: Message): StringSchema<NonNullable<TType>, TContext, TDefault, TFlags>;
notRequired(): StringSchema<Maybe<TType>, TContext, TDefault, TFlags>;
nullable(msg?: Message<any>): StringSchema<TType | null, TContext, TDefault, TFlags>;
nonNullable(): StringSchema<NotNull<TType>, TContext, TDefault, TFlags>;
strip(enabled: false): StringSchema<TType, TContext, TDefault, UnsetFlag<TFlags, 's'>>;
strip(enabled?: true): StringSchema<TType, TContext, TDefault, SetFlag<TFlags, 's'>>;
}

@@ -17,7 +17,7 @@ "use strict";

// eslint-disable-next-line
let rEmail = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i; // eslint-disable-next-line
let rEmail = // eslint-disable-next-line
/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
let rUrl = // eslint-disable-next-line
/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i; // eslint-disable-next-line
let rUrl = /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i; // eslint-disable-next-line
let rUUID = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;

@@ -24,0 +24,0 @@

import type { AnySchema } from './schema';
import type Lazy from './Lazy';
export declare type AnyObject = Record<string, any>;
export declare type SchemaLike = AnySchema | Lazy<any>;
import type { AnyObject } from './util/objectTypes';
import type { ISchema } from './util/types';
export type { ISchema, AnyObject, AnySchema };
export declare type Callback<T = any> = (err: Error | null, value?: T) => void;

@@ -36,3 +36,3 @@ export declare type TransformFunction<T extends AnySchema> = (this: T, value: any, originalValue: any, schema: T) => any;

from?: {
schema: AnySchema;
schema: ISchema<any, TContext>;
value: any;

@@ -39,0 +39,0 @@ }[];

@@ -1,1 +0,5 @@

"use strict";
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

@@ -5,2 +5,3 @@ import ValidationError from '../ValidationError';

import type { AnySchema } from '../schema';
import { ISchema } from './types';
export declare type CreateErrorOptions = {

@@ -16,2 +17,6 @@ path?: string;

parent: any;
from?: Array<{
schema: ISchema<any, TContext>;
value: any;
}>;
schema: any;

@@ -21,3 +26,3 @@ resolve: <T>(value: T | Reference<T>) => T;

};
export declare type TestFunction<T = unknown, TContext = {}> = (this: TestContext<TContext>, value: T, context: TestContext<TContext>) => boolean | ValidationError | Promise<boolean | ValidationError>;
export declare type TestFunction<T = unknown, TContext = {}> = (this: TestContext<TContext>, value: T, context: TestContext<TContext>) => void | boolean | ValidationError | Promise<boolean | ValidationError>;
export declare type TestOptions<TSchema extends AnySchema = AnySchema> = {

@@ -48,9 +53,9 @@ value: any;

}): {
<TSchema extends AnySchema<any, any> = AnySchema<any, any>>({ value, path, label, options, originalValue, sync, ...rest }: TestOptions<TSchema>, cb: Callback): void;
<TSchema extends AnySchema<any, import("./objectTypes").AnyObject, any, import("./types").Flags> = AnySchema<any, import("./objectTypes").AnyObject, any, import("./types").Flags>>({ value, path, label, options, originalValue, sync, ...rest }: TestOptions<TSchema>, cb: Callback): void;
OPTIONS: {
name?: string | undefined;
test: TestFunction;
params?: Record<string, unknown> | undefined;
message?: string | Record<string | number | symbol, unknown> | ((params: any) => unknown) | undefined;
params?: ExtraParams | undefined;
message?: Message<any> | undefined;
};
};

@@ -74,3 +74,3 @@ "use strict";

if (_ValidationError.default.isError(validOrError)) cb(validOrError);else if (!validOrError) cb(createError());else cb(null, validOrError);
});
}).catch(cb);
} catch (err) {

@@ -77,0 +77,0 @@ cb(err);

@@ -1,2 +0,2 @@

declare const _default: (value: any) => value is null | undefined;
export default _default;
declare const isAbsent: (value: any) => value is null | undefined;
export default isAbsent;

@@ -8,4 +8,5 @@ "use strict";

var _default = value => value == null;
const isAbsent = value => value == null;
var _default = isAbsent;
exports.default = _default;

@@ -1,3 +0,3 @@

import type { SchemaLike } from '../types';
declare const _default: (obj: any) => obj is SchemaLike;
export default _default;
import type { ISchema } from './types';
declare const isSchema: (obj: any) => obj is ISchema<any, import("./objectTypes").AnyObject, any, any>;
export default isSchema;

@@ -8,4 +8,5 @@ "use strict";

var _default = obj => obj && obj.__isYupSchema__;
const isSchema = obj => obj && obj.__isYupSchema__;
var _default = isSchema;
exports.default = _default;

@@ -1,2 +0,2 @@

export declare function getIn(schema: any, path: string, value: any, context?: any): {
export declare function getIn(schema: any, path: string, value?: any, context?: any): {
parent: any;

@@ -6,3 +6,3 @@ parentPath: string;

};
declare const reach: (obj: {}, path: string, value: any, context: any) => any;
declare const reach: (obj: {}, path: string, value?: any, context?: any) => any;
export default reach;

@@ -6,4 +6,4 @@ "use strict";

});
exports.default = void 0;
exports.getIn = getIn;
exports.default = void 0;

@@ -10,0 +10,0 @@ var _propertyExpr = require("property-expr");

@@ -9,7 +9,7 @@ import Reference from '../Reference';

toArray(): unknown[];
resolveAll(resolve: (v: unknown) => unknown): unknown;
add(value: unknown): void;
delete(value: unknown): void;
has(value: unknown, resolve: (v: unknown) => unknown): boolean;
clone(): ReferenceSet;
merge(newItems: ReferenceSet, removeItems: ReferenceSet): ReferenceSet;
}

@@ -14,2 +14,4 @@ "use strict";

constructor() {
this.list = void 0;
this.refs = void 0;
this.list = new Set();

@@ -37,2 +39,6 @@ this.refs = new Map();

resolveAll(resolve) {
return this.toArray().reduce((acc, e) => acc.concat(_Reference.default.isRef(e) ? resolve(e) : e), []);
}
add(value) {

@@ -46,12 +52,2 @@ _Reference.default.isRef(value) ? this.refs.set(value.key, value) : this.list.add(value);

has(value, resolve) {
if (this.list.has(value)) return true;
let item,
values = this.refs.values();
while (item = values.next(), !item.done) if (resolve(item.value) === value) return true;
return false;
}
clone() {

@@ -58,0 +54,0 @@ const next = new ReferenceSet();

@@ -1,2 +0,2 @@

import { ObjectShape } from '../object';
export default function sortFields(fields: ObjectShape, excludes?: readonly string[]): string[];
import { ObjectShape } from './objectTypes';
export default function sortFields(fields: ObjectShape, excludedEdges?: readonly [string, string][]): string[];

@@ -19,10 +19,11 @@ "use strict";

// @ts-expect-error
function sortFields(fields, excludes = []) {
function sortFields(fields, excludedEdges = []) {
let edges = [];
let nodes = [];
let nodes = new Set();
let excludes = new Set(excludedEdges.map(([a, b]) => `${a}-${b}`));
function addNode(depPath, key) {
let node = (0, _propertyExpr.split)(depPath)[0];
if (!~nodes.indexOf(node)) nodes.push(node);
if (!~excludes.indexOf(`${key}-${node}`)) edges.push([key, node]);
nodes.add(node);
if (!excludes.has(`${key}-${node}`)) edges.push([key, node]);
}

@@ -32,7 +33,7 @@

let value = fields[key];
if (!~nodes.indexOf(key)) nodes.push(key);
nodes.add(key);
if (_Reference.default.isRef(value) && value.isSibling) addNode(value.path, key);else if ((0, _isSchema.default)(value) && 'deps' in value) value.deps.forEach(path => addNode(path, key));
}
return _toposort.default.array(nodes, edges).reverse();
return _toposort.default.array(Array.from(nodes), edges).reverse();
}

@@ -1,34 +0,26 @@

import type { AnyObject, Preserve } from '../types';
import type { ResolveOptions } from '../Condition';
import type { CastOptions, SchemaFieldDescription } from '../schema';
import type { AnyObject, Callback, Optionals, Preserve, ValidateOptions } from '../types';
export declare type Defined<T> = T extends undefined ? never : T;
export declare type NotNull<T> = T extends null ? never : T;
export declare type TypedSchema = {
__type: any;
__outputType: any;
};
export declare type TypeOf<TSchema extends TypedSchema> = TSchema['__type'];
export declare type Asserts<TSchema extends TypedSchema> = TSchema['__outputType'];
export interface ISchema<T, C = AnyObject, F extends Flags = any, D = any> {
__flags: F;
__context: C;
__outputType: T;
__default: D;
cast(value: any, options?: CastOptions<C>): T;
validate(value: any, options?: ValidateOptions<C>, maybeCb?: Callback): Promise<T>;
describe(options?: ResolveOptions<C>): SchemaFieldDescription;
resolve(options: ResolveOptions<C>): ISchema<T, C, F>;
}
export declare type InferType<T extends ISchema<any, any>> = T['__outputType'];
export declare type Thunk<T> = T | (() => T);
export declare type If<T, Y, N> = Exclude<T, undefined> extends never ? Y : N;
export declare type _<T> = T extends {} ? {
[k in keyof T]: _<T[k]>;
[k in keyof T]: T[k];
} : T;
declare type OptionalKeys<T extends {}> = {
[k in keyof T]: undefined extends T[k] ? k : never;
}[keyof T];
declare type RequiredKeys<T extends object> = Exclude<keyof T, OptionalKeys<T>>;
export declare type MakePartial<T extends object> = {
[k in OptionalKeys<T>]?: T[k];
} & {
[k in RequiredKeys<T>]: T[k];
};
export declare type Flags = 's' | 'd' | '';
export interface Config<C = AnyObject, F extends Flags = ''> {
context: C;
flags: F;
}
export declare type AnyConfig = Config<any, any>;
export declare type MergeConfig<T extends AnyConfig, U extends AnyConfig> = Config<T['context'] & U['context'], T['flags'] | U['flags']>;
export declare type SetFlag<C extends AnyConfig, F extends Flags> = C extends Config<infer Context, infer Old> ? Config<Context, Exclude<Old, ''> | F> : never;
export declare type UnsetFlag<C extends AnyConfig, F extends Flags> = C extends Config<infer Context, infer Old> ? Exclude<Old, F> extends never ? Config<Context, ''> : Config<Context, Exclude<Old, F>> : never;
export declare type ToggleDefault<C extends AnyConfig, D> = Preserve<D, undefined> extends never ? SetFlag<C, 'd'> : UnsetFlag<C, 'd'>;
export {};
export declare type SetFlag<Old extends Flags, F extends Flags> = Exclude<Old, ''> | F;
export declare type UnsetFlag<Old extends Flags, F extends Flags> = Exclude<Old, F> extends never ? '' : Exclude<Old, F>;
export declare type ToggleDefault<F extends Flags, D> = Preserve<D, undefined> extends never ? SetFlag<F, 'd'> : UnsetFlag<F, 'd'>;
export declare type ResolveFlags<T, F extends Flags> = Preserve<F, 's'> extends never ? Extract<F, 'd'> extends never ? T : Defined<T> : never;
export declare type Concat<T, U> = NonNullable<T> & NonNullable<U> extends never ? never : (NonNullable<T> & NonNullable<U>) | Optionals<U>;

@@ -1,1 +0,5 @@

"use strict";
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

@@ -35,2 +35,8 @@ "use strict";

super();
this.value = void 0;
this.path = void 0;
this.type = void 0;
this.errors = void 0;
this.params = void 0;
this.inner = void 0;
this.name = 'ValidationError';

@@ -37,0 +43,0 @@ this.value = value;

{
"name": "yup",
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.3",
"description": "Dead simple Object schema validation",

@@ -63,3 +63,3 @@ "main": "lib/index.js",

"testPathIgnorePatterns": [
"helpers\\.js",
"helpers\\.ts",
"\\.eslintrc\\.js",

@@ -70,45 +70,39 @@ "types\\.ts"

"devDependencies": {
"@4c/cli": "^2.1.12",
"@4c/rollout": "^2.1.11",
"@4c/tsconfig": "^0.3.1",
"@babel/cli": "7.12.10",
"@babel/core": "7.12.10",
"@babel/plugin-proposal-logical-assignment-operators": "^7.12.1",
"@babel/preset-typescript": "^7.12.7",
"@typescript-eslint/eslint-plugin": "^4.9.1",
"@typescript-eslint/parser": "^4.9.1",
"babel-core": "^7.0.0-bridge.0",
"@4c/cli": "^3.0.1",
"@4c/rollout": "^3.0.1",
"@4c/tsconfig": "^0.4.0",
"@babel/cli": "^7.15.7",
"@babel/core": "^7.15.8",
"@babel/plugin-proposal-logical-assignment-operators": "^7.14.5",
"@babel/preset-typescript": "^7.15.0",
"@types/jest": "^27.0.3",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.3",
"babel-jest": "^27.2.5",
"babel-plugin-transform-rename-import": "^2.3.0",
"babel-preset-jason": "^6.3.0",
"benchmark": "^2.1.4",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"dirty-chai": "^2.0.1",
"doctoc": "^2.0.0",
"eslint": "^7.15.0",
"doctoc": "^2.0.1",
"eslint": "^7.12.0",
"eslint-config-jason": "^8.1.1",
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-react": "^7.21.5",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jest": "^25.0.1",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-ts-expect": "^2.0.0",
"husky": "^4.3.6",
"jest": "^26.6.3",
"lint-staged": "^10.5.3",
"prettier": "^2.2.1",
"rollup": "^2.35.1",
"eslint-plugin-typescript": "^0.14.0",
"hookem": "^2.0.1",
"jest": "^27.2.5",
"lint-staged": "^11.2.3",
"prettier": "^2.4.1",
"rollup": "^2.58.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-filesize": "^8.0.2",
"rollup-plugin-filesize": "^9.1.1",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-size-snapshot": "^0.12.0",
"sinon": "^9.2.2",
"sinon-chai": "^3.5.0",
"synchronous-promise": "^2.0.15",
"typescript": "^4.1.3"
"typescript": "^4.4.3"
},
"dependencies": {
"@babel/runtime": "^7.12.5",
"nanoclone": "^0.2.1",

@@ -118,6 +112,3 @@ "property-expr": "^2.0.4",

"toposort": "^2.0.2"
},
"engines": {
"node": ">=10"
}
}

@@ -414,3 +414,3 @@ # Yup

(relevant for objects or arrays).
- `context`: any context needed for validating schema conditions (see: `when()`)
- `context`: any context needed for validating schema conditions (see: [`when()`](#mixedwhenkeys-string--arraystring-builder-object--value-schema-schema-schema))

@@ -545,3 +545,3 @@ ```js

declaration, and only happen once over the lifetime of the schema, so performance isn't an issue.
However certain mutations _do_ occur at cast/validation time, (such as conditional schema using `when()`), or
However certain mutations _do_ occur at cast/validation time, (such as conditional schema using [`when()`](#mixedwhenkeys-string--arraystring-builder-object--value-schema-schema-schema)), or
when instantiating a schema object.

@@ -609,4 +609,6 @@

Whitelist a set of values. Values added are automatically removed from any blacklist if they are in it.
The `${values}` interpolation can be used in the `message` argument.
Only allow values from set of values. Values added are removed from any `notOneOf` values if present.
The `${values}` interpolation can be used in the `message` argument. If a ref or refs are provided,
the `${resolved}` interpolation can be used in the message argument to get the resolved values that were checked
at validation time.

@@ -626,4 +628,6 @@ Note that `undefined` does not fail this validator, even when `undefined` is not included in `arrayOfValues`.

Blacklist a set of values. Values added are automatically removed from any whitelist if they are in it.
The `${values}` interpolation can be used in the `message` argument.
Disallow values from a set of values. Values added are removed from `oneOf` values if present.
The `${values}` interpolation can be used in the `message` argument. If a ref or refs are provided,
the `${resolved}` interpolation can be used in the message argument to get the resolved values that were checked
at validation time.

@@ -727,3 +731,3 @@ ```js

'${path} is not Jimmy',
async (value, context) => (await fetch('/is-jimmy/' + value)).responseText === 'true',
async (value, testContext) => (await fetch('/is-jimmy/' + value)).responseText === 'true',
});

@@ -735,13 +739,12 @@

Test functions are called with a special context, or `this` value, that exposes some useful metadata
and functions. Older versions just expose the `this` context using `function ()`, not arrow-func,
but now it's exposed too as a second argument of the test functions. It's allow you decide which
approach you prefer.
Test functions are called with a special context value, as the second argument, that exposes some useful metadata
and functions. For non arrow functions, the test context is also set as the function `this`. Watch out, if you access
it via `this` it won't work in an arrow function.
- `this.path`: the string path of the current validation
- `this.schema`: the resolved schema object that the test is running against.
- `this.options`: the `options` object that validate() or isValid() was called with
- `this.parent`: in the case of nested schema, this is the value of the parent object
- `this.originalValue`: the original value that is being tested
- `this.createError(Object: { path: String, message: String, params: Object })`: create and return a
- `testContext.path`: the string path of the current validation
- `testContext.schema`: the resolved schema object that the test is running against.
- `testContext.options`: the `options` object that validate() or isValid() was called with
- `testContext.parent`: in the case of nested schema, this is the value of the parent object
- `testContext.originalValue`: the original value that is being tested
- `testContext.createError(Object: { path: String, message: String, params: Object })`: create and return a
validation error. Useful for dynamically setting the `path`, `params`, or more likely, the error `message`.

@@ -790,3 +793,3 @@ If either option is omitted it will use the current path, or default message.

Adds a transformation to the transform chain. Transformations are central to the casting process,
default transforms for each type coerce values to the specific type (as verified by [`isType()`](mixedistypevalue)). transforms are run before validations and only applied when the schema is not marked as `strict` (the default). Some types have built in transformations.
default transforms for each type coerce values to the specific type (as verified by [`isType()`](#mixedistypevalue-any-boolean)). transforms are run before validations and only applied when the schema is not marked as `strict` (the default). Some types have built in transformations.

@@ -793,0 +796,0 @@ Transformations are useful for arbitrarily altering how the object is cast, **however, you should take care

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc