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.1 to 1.0.0-alpha.2

10

es/array.d.ts

@@ -1,4 +0,4 @@

import type { AnyObject, InternalOptions, Callback, Message, Maybe, Optionals } from './types';
import type { AnyObject, InternalOptions, Callback, Message, Maybe } from './types';
import type Reference from './Reference';
import { Asserts, Config, Defined, NotNull, SetFlag, Thunk, ToggleDefault, TypeOf } from './util/types';
import { Asserts, Config, Defined, NotNull, SetFlag, Thunk, ToggleDefault } from './util/types';
import BaseSchema, { AnySchema, SchemaInnerTypeDescription, SchemaSpec } from './schema';

@@ -8,7 +8,7 @@ import Lazy from './Lazy';

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, "">, TypeOf<T>[] | undefined>;
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 namespace create {
var prototype: ArraySchema<any, any, any>;
}
export default class ArraySchema<T extends AnySchema | Lazy<any, any>, C extends Config<any, any> = Config, TIn extends Maybe<TypeOf<T>[]> = TypeOf<T>[] | undefined> extends BaseSchema<TIn, Asserts<T>[] | Optionals<TIn>, C> {
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;

@@ -37,3 +37,3 @@ constructor(type?: T);

}
export default interface ArraySchema<T extends AnySchema | Lazy<any, any>, C extends Config<any, any> = Config, TIn extends Maybe<TypeOf<T>[]> = TypeOf<T>[] | undefined> extends BaseSchema<TIn, Asserts<T>[] | Optionals<TIn>, C> {
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>;

@@ -40,0 +40,0 @@ defined(msg?: Message): ArraySchema<T, C, Defined<TIn>>;

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

}
export default class BooleanSchema<TType extends Maybe<boolean> = boolean | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TType, TConfig> {
export default class BooleanSchema<TType extends Maybe<boolean> = boolean | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
constructor();

@@ -19,3 +19,3 @@ protected _typeCheck(v: any): v is NonNullable<TType>;

}
export default interface BooleanSchema<TType extends Maybe<boolean>, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TType, TConfig> {
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>>;

@@ -22,0 +22,0 @@ concat<TOther extends BooleanSchema<any, any>>(schema: TOther): TOther;

@@ -15,3 +15,3 @@ import Ref from './Reference';

}
export default class DateSchema<TType extends Maybe<Date> = Date | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TType, TConfig> {
export default class DateSchema<TType extends Maybe<Date> = Date | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
static INVALID_DATE: Date;

@@ -28,3 +28,3 @@ constructor();

}
export default interface DateSchema<TType extends Maybe<Date>, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TType, TConfig> {
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>>;

@@ -31,0 +31,0 @@ concat<TOther extends DateSchema<any, any>>(schema: TOther): TOther;

@@ -19,5 +19,5 @@ import MixedSchema, { create as mixedCreate } from './mixed';

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], T[k], Config>;
[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, T, 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>;

@@ -24,0 +24,0 @@ export type { SchemaOf, TypeOf, Asserts, Asserts as InferType, AnySchema };

import { Maybe, Message, Optionals } from './types';
import type { Config, Defined, Thunk, ToggleDefault } from './util/types';
import BaseSchema from './schema';
export declare class MixedSchema<TType = any, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TType, TConfig> {
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, any, IC>): MixedSchema<NonNullable<TType> | Optionals<IT>, TConfig & IC>;
concat<IT, IC extends Config<any, any>>(schema: BaseSchema<IT, IC>): MixedSchema<NonNullable<TType> | Optionals<IT>, TConfig & IC>;
concat(schema: this): this;

@@ -9,0 +9,0 @@ defined(msg?: Message): MixedSchema<Defined<TType>, TConfig>;

@@ -13,3 +13,3 @@ import type { AnyObject, Maybe, Message } from './types';

}
export default class NumberSchema<TType extends Maybe<number> = number | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TType, TConfig> {
export default class NumberSchema<TType extends Maybe<number> = number | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
constructor();

@@ -39,3 +39,3 @@ protected _typeCheck(value: any): value is NonNullable<TType>;

}
export default interface NumberSchema<TType extends Maybe<number> = number | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TType, TConfig> {
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'>>;

@@ -42,0 +42,0 @@ default<D extends Maybe<TType>>(def: Thunk<D>): NumberSchema<TType, ToggleDefault<TConfig, D>>;

@@ -23,3 +23,5 @@ import { InternalOptions, Callback, Maybe, Optionals, Preserve, Message } from './types';

[K in keyof S]: FieldType<S[K], '__outputType'>;
}>;
}> & {
[k: string]: any;
};
export declare type PartialSchema<S extends ObjectShape> = {

@@ -34,3 +36,3 @@ [K in keyof S]: S[K] extends BaseSchema ? ReturnType<S[K]['optional']> : S[K];

};
export default class ObjectSchema<TShape extends ObjectShape, TConfig extends Config<any, any> = Config<AnyObject, 'd'>, TIn extends Maybe<TypeOfShape<TShape>> = TypeOfShape<TShape> | undefined> extends BaseSchema<TIn, AssertsShape<TShape> | Optionals<TIn>, TConfig> {
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;

@@ -46,3 +48,3 @@ spec: ObjectSchemaSpec;

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, TypeOfShape<TShape & S> | Optionals<IType>> : never;
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(schema: this): this;

@@ -52,7 +54,7 @@ protected _getDefault(): any;

private setFields;
shape<TNextShape extends ObjectShape>(additions: TNextShape, excludes?: [string, string][]): ObjectSchema<Assign<TShape, TNextShape>, TConfig, Extract<TIn, null | undefined> | TypeOfShape<Assign<TShape, TNextShape>>>;
partial(): ObjectSchema<PartialSchema<TShape>, TConfig, Extract<TIn, null | undefined> | TypeOfShape<PartialSchema<TShape>>>;
deepPartial(): ObjectSchema<DeepPartialSchema<TShape>, TConfig, Optionals<TIn> | undefined | TypeOfShape<DeepPartialSchema<TShape>>>;
pick<TKey extends keyof TShape>(keys: TKey[]): ObjectSchema<Pick<TShape, TKey>, TConfig, Extract<TIn, null | undefined> | TypeOfShape<Pick<TShape, TKey>>>;
omit<TKey extends keyof TShape>(keys: TKey[]): ObjectSchema<Pick<TShape, Exclude<keyof TShape, TKey>>, TConfig, Extract<TIn, null | undefined> | TypeOfShape<Pick<TShape, Exclude<keyof TShape, TKey>>>>;
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;

@@ -67,7 +69,7 @@ noUnknown(noAllow?: boolean, message?: Message<any>): this;

}
export declare function create<TShape extends ObjectShape = {}>(spec?: TShape): ObjectSchema<TShape, Config<Record<string, any>, "d">, TypeOfShape<TShape> | undefined>;
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<TypeOfShape<TShape>> = TypeOfShape<TShape> | undefined> extends BaseSchema<TIn, AssertsShape<TShape> | Optionals<TIn>, TConfig> {
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>;

@@ -74,0 +76,0 @@ defined(msg?: Message): ObjectSchema<TShape, TConfig, Defined<TIn>>;

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 snakeCase from 'lodash/snakeCase';
import camelCase from 'lodash/camelCase'; // @ts-ignore
// @ts-ignore
import { getter, normalizePath, join } from 'property-expr';
import { camelCase, snakeCase } from 'tiny-case';
import { object as locale } from './locale';

@@ -8,0 +7,0 @@ import sortFields from './util/sortFields';

@@ -8,3 +8,3 @@ import { ConditionOptions, ResolveOptions } from './Condition';

export { Config };
export declare type ConfigOf<T> = T extends AnySchema<any, any, infer C> ? C : never;
export declare type ConfigOf<T> = T extends AnySchema<any, infer C> ? C : never;
export declare type ContextOf<T> = ConfigOf<T>['context'];

@@ -29,3 +29,3 @@ export declare type FlagsOf<T> = T extends AnySchema ? T['__flags'] : never;

};
export declare type AnySchema<TType = any, TOut = any, C extends Config = any> = BaseSchema<TType, TOut, C>;
export declare type AnySchema<TType = any, C extends Config = any> = BaseSchema<TType, C>;
export interface CastOptions<C = {}> {

@@ -68,6 +68,6 @@ parent?: any;

}
export default abstract class BaseSchema<TType = any, TOut = TType, TConfig extends Config<any, any> = Config> {
export default abstract class BaseSchema<TType = any, TConfig extends Config<any, any> = Config> {
readonly type: string;
readonly __type: TType;
readonly __outputType: ResolveFlags<TOut, TConfig['flags']>;
readonly __outputType: ResolveFlags<TType, TConfig['flags']>;
readonly __flags: TConfig['flags'];

@@ -151,3 +151,3 @@ readonly __isYupSchema__: boolean;

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

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

}
export default interface BaseSchema<TType = any, TOut = TType, TConfig extends Config<any, any> = Config> {
export default interface BaseSchema<TType = any, TConfig extends Config<any, any> = Config> {
validateAt(path: string, value: any, options?: ValidateOptions<TConfig['context']>): Promise<any>;

@@ -163,0 +163,0 @@ validateSyncAt(path: string, value: any, options?: ValidateOptions<TConfig['context']>): any;

@@ -22,3 +22,3 @@ import { MixedLocale } from './locale';

export { create };
export default class StringSchema<TType extends Maybe<string> = string | undefined, TConfig extends AnyConfig = Config> extends BaseSchema<TType, TType, TConfig> {
export default class StringSchema<TType extends Maybe<string> = string | undefined, TConfig extends AnyConfig = Config> extends BaseSchema<TType, TConfig> {
constructor();

@@ -51,3 +51,3 @@ 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, TType, TConfig> {
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>>;

@@ -54,0 +54,0 @@ oneOf<U extends TType>(arrayOfValues: ReadonlyArray<U | Reference>, message?: MixedLocale['oneOf']): StringSchema<U | Optionals<TType>, TConfig>;

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

}): {
<TSchema extends AnySchema<any, any, any> = AnySchema<any, any, any>>({ value, path, label, options, originalValue, sync, ...rest }: TestOptions<TSchema>, cb: Callback): void;
<TSchema extends AnySchema<any, any> = AnySchema<any, any>>({ value, path, label, options, originalValue, sync, ...rest }: TestOptions<TSchema>, cb: Callback): void;
OPTIONS: {

@@ -48,0 +48,0 @@ name?: string | undefined;

@@ -1,4 +0,4 @@

import type { AnyObject, InternalOptions, Callback, Message, Maybe, Optionals } from './types';
import type { AnyObject, InternalOptions, Callback, Message, Maybe } from './types';
import type Reference from './Reference';
import { Asserts, Config, Defined, NotNull, SetFlag, Thunk, ToggleDefault, TypeOf } from './util/types';
import { Asserts, Config, Defined, NotNull, SetFlag, Thunk, ToggleDefault } from './util/types';
import BaseSchema, { AnySchema, SchemaInnerTypeDescription, SchemaSpec } from './schema';

@@ -8,7 +8,7 @@ import Lazy from './Lazy';

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, "">, TypeOf<T>[] | undefined>;
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 namespace create {
var prototype: ArraySchema<any, any, any>;
}
export default class ArraySchema<T extends AnySchema | Lazy<any, any>, C extends Config<any, any> = Config, TIn extends Maybe<TypeOf<T>[]> = TypeOf<T>[] | undefined> extends BaseSchema<TIn, Asserts<T>[] | Optionals<TIn>, C> {
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;

@@ -37,3 +37,3 @@ constructor(type?: T);

}
export default interface ArraySchema<T extends AnySchema | Lazy<any, any>, C extends Config<any, any> = Config, TIn extends Maybe<TypeOf<T>[]> = TypeOf<T>[] | undefined> extends BaseSchema<TIn, Asserts<T>[] | Optionals<TIn>, C> {
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>;

@@ -40,0 +40,0 @@ defined(msg?: Message): ArraySchema<T, C, Defined<TIn>>;

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

}
export default class BooleanSchema<TType extends Maybe<boolean> = boolean | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TType, TConfig> {
export default class BooleanSchema<TType extends Maybe<boolean> = boolean | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
constructor();

@@ -19,3 +19,3 @@ protected _typeCheck(v: any): v is NonNullable<TType>;

}
export default interface BooleanSchema<TType extends Maybe<boolean>, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TType, TConfig> {
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>>;

@@ -22,0 +22,0 @@ concat<TOther extends BooleanSchema<any, any>>(schema: TOther): TOther;

@@ -15,3 +15,3 @@ import Ref from './Reference';

}
export default class DateSchema<TType extends Maybe<Date> = Date | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TType, TConfig> {
export default class DateSchema<TType extends Maybe<Date> = Date | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
static INVALID_DATE: Date;

@@ -28,3 +28,3 @@ constructor();

}
export default interface DateSchema<TType extends Maybe<Date>, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TType, TConfig> {
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>>;

@@ -31,0 +31,0 @@ concat<TOther extends DateSchema<any, any>>(schema: TOther): TOther;

@@ -19,5 +19,5 @@ import MixedSchema, { create as mixedCreate } from './mixed';

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], T[k], Config>;
[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, T, 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>;

@@ -24,0 +24,0 @@ export type { SchemaOf, TypeOf, Asserts, Asserts as InferType, AnySchema };

import { Maybe, Message, Optionals } from './types';
import type { Config, Defined, Thunk, ToggleDefault } from './util/types';
import BaseSchema from './schema';
export declare class MixedSchema<TType = any, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TType, TConfig> {
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, any, IC>): MixedSchema<NonNullable<TType> | Optionals<IT>, TConfig & IC>;
concat<IT, IC extends Config<any, any>>(schema: BaseSchema<IT, IC>): MixedSchema<NonNullable<TType> | Optionals<IT>, TConfig & IC>;
concat(schema: this): this;

@@ -9,0 +9,0 @@ defined(msg?: Message): MixedSchema<Defined<TType>, TConfig>;

@@ -13,3 +13,3 @@ import type { AnyObject, Maybe, Message } from './types';

}
export default class NumberSchema<TType extends Maybe<number> = number | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TType, TConfig> {
export default class NumberSchema<TType extends Maybe<number> = number | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TConfig> {
constructor();

@@ -39,3 +39,3 @@ protected _typeCheck(value: any): value is NonNullable<TType>;

}
export default interface NumberSchema<TType extends Maybe<number> = number | undefined, TConfig extends Config<any, any> = Config> extends BaseSchema<TType, TType, TConfig> {
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'>>;

@@ -42,0 +42,0 @@ default<D extends Maybe<TType>>(def: Thunk<D>): NumberSchema<TType, ToggleDefault<TConfig, D>>;

@@ -23,3 +23,5 @@ import { InternalOptions, Callback, Maybe, Optionals, Preserve, Message } from './types';

[K in keyof S]: FieldType<S[K], '__outputType'>;
}>;
}> & {
[k: string]: any;
};
export declare type PartialSchema<S extends ObjectShape> = {

@@ -34,3 +36,3 @@ [K in keyof S]: S[K] extends BaseSchema ? ReturnType<S[K]['optional']> : S[K];

};
export default class ObjectSchema<TShape extends ObjectShape, TConfig extends Config<any, any> = Config<AnyObject, 'd'>, TIn extends Maybe<TypeOfShape<TShape>> = TypeOfShape<TShape> | undefined> extends BaseSchema<TIn, AssertsShape<TShape> | Optionals<TIn>, TConfig> {
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;

@@ -46,3 +48,3 @@ spec: ObjectSchemaSpec;

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, TypeOfShape<TShape & S> | Optionals<IType>> : never;
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(schema: this): this;

@@ -52,7 +54,7 @@ protected _getDefault(): any;

private setFields;
shape<TNextShape extends ObjectShape>(additions: TNextShape, excludes?: [string, string][]): ObjectSchema<Assign<TShape, TNextShape>, TConfig, Extract<TIn, null | undefined> | TypeOfShape<Assign<TShape, TNextShape>>>;
partial(): ObjectSchema<PartialSchema<TShape>, TConfig, Extract<TIn, null | undefined> | TypeOfShape<PartialSchema<TShape>>>;
deepPartial(): ObjectSchema<DeepPartialSchema<TShape>, TConfig, Optionals<TIn> | undefined | TypeOfShape<DeepPartialSchema<TShape>>>;
pick<TKey extends keyof TShape>(keys: TKey[]): ObjectSchema<Pick<TShape, TKey>, TConfig, Extract<TIn, null | undefined> | TypeOfShape<Pick<TShape, TKey>>>;
omit<TKey extends keyof TShape>(keys: TKey[]): ObjectSchema<Pick<TShape, Exclude<keyof TShape, TKey>>, TConfig, Extract<TIn, null | undefined> | TypeOfShape<Pick<TShape, Exclude<keyof TShape, TKey>>>>;
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;

@@ -67,7 +69,7 @@ noUnknown(noAllow?: boolean, message?: Message<any>): this;

}
export declare function create<TShape extends ObjectShape = {}>(spec?: TShape): ObjectSchema<TShape, Config<Record<string, any>, "d">, TypeOfShape<TShape> | undefined>;
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<TypeOfShape<TShape>> = TypeOfShape<TShape> | undefined> extends BaseSchema<TIn, AssertsShape<TShape> | Optionals<TIn>, TConfig> {
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>;

@@ -74,0 +76,0 @@ defined(msg?: Message): ObjectSchema<TShape, TConfig, Defined<TIn>>;

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

var _snakeCase = _interopRequireDefault(require("lodash/snakeCase"));
var _propertyExpr = require("property-expr");
var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
var _tinyCase = require("tiny-case");
var _propertyExpr = require("property-expr");
var _locale = require("./locale");

@@ -387,11 +385,11 @@

camelCase() {
return this.transformKeys(_camelCase.default);
return this.transformKeys(_tinyCase.camelCase);
}
snakeCase() {
return this.transformKeys(_snakeCase.default);
return this.transformKeys(_tinyCase.snakeCase);
}
constantCase() {
return this.transformKeys(key => (0, _snakeCase.default)(key).toUpperCase());
return this.transformKeys(key => (0, _tinyCase.snakeCase)(key).toUpperCase());
}

@@ -398,0 +396,0 @@

@@ -8,3 +8,3 @@ import { ConditionOptions, ResolveOptions } from './Condition';

export { Config };
export declare type ConfigOf<T> = T extends AnySchema<any, any, infer C> ? C : never;
export declare type ConfigOf<T> = T extends AnySchema<any, infer C> ? C : never;
export declare type ContextOf<T> = ConfigOf<T>['context'];

@@ -29,3 +29,3 @@ export declare type FlagsOf<T> = T extends AnySchema ? T['__flags'] : never;

};
export declare type AnySchema<TType = any, TOut = any, C extends Config = any> = BaseSchema<TType, TOut, C>;
export declare type AnySchema<TType = any, C extends Config = any> = BaseSchema<TType, C>;
export interface CastOptions<C = {}> {

@@ -68,6 +68,6 @@ parent?: any;

}
export default abstract class BaseSchema<TType = any, TOut = TType, TConfig extends Config<any, any> = Config> {
export default abstract class BaseSchema<TType = any, TConfig extends Config<any, any> = Config> {
readonly type: string;
readonly __type: TType;
readonly __outputType: ResolveFlags<TOut, TConfig['flags']>;
readonly __outputType: ResolveFlags<TType, TConfig['flags']>;
readonly __flags: TConfig['flags'];

@@ -151,3 +151,3 @@ readonly __isYupSchema__: boolean;

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

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

}
export default interface BaseSchema<TType = any, TOut = TType, TConfig extends Config<any, any> = Config> {
export default interface BaseSchema<TType = any, TConfig extends Config<any, any> = Config> {
validateAt(path: string, value: any, options?: ValidateOptions<TConfig['context']>): Promise<any>;

@@ -163,0 +163,0 @@ validateSyncAt(path: string, value: any, options?: ValidateOptions<TConfig['context']>): any;

@@ -22,3 +22,3 @@ import { MixedLocale } from './locale';

export { create };
export default class StringSchema<TType extends Maybe<string> = string | undefined, TConfig extends AnyConfig = Config> extends BaseSchema<TType, TType, TConfig> {
export default class StringSchema<TType extends Maybe<string> = string | undefined, TConfig extends AnyConfig = Config> extends BaseSchema<TType, TConfig> {
constructor();

@@ -51,3 +51,3 @@ 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, TType, TConfig> {
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>>;

@@ -54,0 +54,0 @@ oneOf<U extends TType>(arrayOfValues: ReadonlyArray<U | Reference>, message?: MixedLocale['oneOf']): StringSchema<U | Optionals<TType>, TConfig>;

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

}): {
<TSchema extends AnySchema<any, any, any> = AnySchema<any, any, any>>({ value, path, label, options, originalValue, sync, ...rest }: TestOptions<TSchema>, cb: Callback): void;
<TSchema extends AnySchema<any, any> = AnySchema<any, any>>({ value, path, label, options, originalValue, sync, ...rest }: TestOptions<TSchema>, cb: Callback): void;
OPTIONS: {

@@ -48,0 +48,0 @@ name?: string | undefined;

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

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

"@babel/preset-typescript": "^7.12.7",
"@typescript-eslint/eslint-plugin": "^4.9.1",
"@typescript-eslint/parser": "^4.9.1",

@@ -112,8 +113,5 @@ "babel-core": "^7.0.0-bridge.0",

"@babel/runtime": "^7.12.5",
"@types/lodash": "^4.14.165",
"@typescript-eslint/eslint-plugin": "^4.9.1",
"lodash": "^4.17.20",
"lodash-es": "^4.17.11",
"nanoclone": "^0.2.1",
"property-expr": "^2.0.4",
"tiny-case": "^1.0.2",
"toposort": "^2.0.2"

@@ -120,0 +118,0 @@ },

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