Comparing version 0.32.1 to 0.32.2
@@ -0,1 +1,12 @@ | ||
## [0.32.2](https://github.com/jquense/yup/compare/v0.32.1...v0.32.2) (2020-12-07) | ||
### Bug Fixes | ||
* **types:** array type with lazy ([ba92dfc](https://github.com/jquense/yup/commit/ba92dfc)), closes [#1146](https://github.com/jquense/yup/issues/1146) | ||
## [0.32.1](https://github.com/jquense/yup/compare/v0.32.0...v0.32.1) (2020-12-04) | ||
@@ -2,0 +13,0 @@ |
@@ -6,8 +6,9 @@ import { MixedLocale } from './locale'; | ||
import BaseSchema, { AnySchema, SchemaInnerTypeDescription, SchemaSpec } from './schema'; | ||
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 = AnySchema>(type?: T): OptionalArraySchema<T, C, TypeOf<T>[] | undefined>; | ||
export declare function create<C extends AnyObject = AnyObject, T extends AnySchema | Lazy<any, any> = AnySchema>(type?: T): OptionalArraySchema<T, C, TypeOf<T>[] | undefined>; | ||
export declare namespace create { | ||
var prototype: ArraySchema<any, any, any, any>; | ||
} | ||
export default class ArraySchema<T extends AnySchema, C extends AnyObject = AnyObject, TIn extends Maybe<TypeOf<T>[]> = TypeOf<T>[] | undefined, TOut extends Maybe<Asserts<T>[]> = Asserts<T>[] | Optionals<TIn>> extends BaseSchema<TIn, C, TOut> { | ||
export default class ArraySchema<T extends AnySchema | Lazy<any, any>, C extends AnyObject = AnyObject, TIn extends Maybe<TypeOf<T>[]> = TypeOf<T>[] | undefined, TOut extends Maybe<Asserts<T>[]> = Asserts<T>[] | Optionals<TIn>> extends BaseSchema<TIn, C, TOut> { | ||
innerType?: T; | ||
@@ -36,3 +37,3 @@ constructor(type?: T); | ||
} | ||
export interface DefinedArraySchema<T extends AnySchema, TContext extends AnyObject, TIn extends Maybe<TypeOf<T>[]>> extends ArraySchema<T, TContext, TIn, Asserts<T>[] | Preserve<TIn, null>> { | ||
export interface DefinedArraySchema<T extends AnySchema | Lazy<any, any>, TContext extends AnyObject, TIn extends Maybe<TypeOf<T>[]>> extends ArraySchema<T, TContext, TIn, Asserts<T>[] | Preserve<TIn, null>> { | ||
default<D extends Maybe<TIn>>(def: Thunk<D>): If<D, DefinedArraySchema<T, TContext, TIn | undefined>, DefinedArraySchema<T, TContext, Defined<TIn>>>; | ||
@@ -46,3 +47,3 @@ defined(msg?: MixedLocale['defined']): this; | ||
} | ||
export interface RequiredArraySchema<T extends AnySchema, TContext extends AnyObject, TIn extends Maybe<TypeOf<T>[]>> extends ArraySchema<T, TContext, TIn, Asserts<T>[]> { | ||
export interface RequiredArraySchema<T extends AnySchema | Lazy<any, any>, TContext extends AnyObject, TIn extends Maybe<TypeOf<T>[]>> extends ArraySchema<T, TContext, TIn, Asserts<T>[]> { | ||
default<D extends Maybe<TIn>>(def: Thunk<D>): If<D, RequiredArraySchema<T, TContext, TIn | undefined>, RequiredArraySchema<T, TContext, Defined<TIn>>>; | ||
@@ -56,3 +57,3 @@ defined(msg?: MixedLocale['defined']): DefinedArraySchema<T, TContext, TIn>; | ||
} | ||
export interface OptionalArraySchema<T extends AnySchema, TContext extends AnyObject = AnyObject, TIn extends Maybe<TypeOf<T>[]> = TypeOf<T>[] | undefined> extends ArraySchema<T, TContext, TIn> { | ||
export interface OptionalArraySchema<T extends AnySchema | Lazy<any, any>, TContext extends AnyObject = AnyObject, TIn extends Maybe<TypeOf<T>[]> = TypeOf<T>[] | undefined> extends ArraySchema<T, TContext, TIn> { | ||
default<D extends Maybe<TIn>>(def: Thunk<D>): If<D, ArraySchema<T, TContext, TIn | undefined>, ArraySchema<T, TContext, Defined<TIn>>>; | ||
@@ -59,0 +60,0 @@ defined(msg?: MixedLocale['defined']): DefinedArraySchema<T, TContext, TIn>; |
@@ -102,4 +102,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); } | ||
tests[idx] = (_, cb) => innerType.validate(item, innerOptions, // @ts-expect-error | ||
cb); | ||
tests[idx] = (_, cb) => innerType.validate(item, innerOptions, cb); | ||
} | ||
@@ -127,3 +126,4 @@ | ||
next.innerType = this.innerType; | ||
if (schema.innerType) next.innerType = next.innerType ? next.innerType.concat(schema.innerType) : schema.innerType; | ||
if (schema.innerType) next.innerType = next.innerType ? // @ts-expect-error Lazy doesn't have concat() | ||
next.innerType.concat(schema.innerType) : schema.innerType; | ||
return next; | ||
@@ -130,0 +130,0 @@ } |
@@ -22,2 +22,3 @@ import MixedSchema, { create as mixedCreate } from './mixed'; | ||
}> : T extends Array<infer E> ? ArraySchema<SchemaOf<E>> : BaseSchema<Maybe<T>, AnyObject, T>; | ||
export declare type AnyObjectSchema = ObjectSchema<any, any, any>; | ||
export type { SchemaOf, TypeOf, Asserts, Asserts as InferType, AnySchema }; | ||
@@ -24,0 +25,0 @@ 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, }; |
@@ -6,8 +6,9 @@ import { MixedLocale } from './locale'; | ||
import BaseSchema, { AnySchema, SchemaInnerTypeDescription, SchemaSpec } from './schema'; | ||
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 = AnySchema>(type?: T): OptionalArraySchema<T, C, TypeOf<T>[] | undefined>; | ||
export declare function create<C extends AnyObject = AnyObject, T extends AnySchema | Lazy<any, any> = AnySchema>(type?: T): OptionalArraySchema<T, C, TypeOf<T>[] | undefined>; | ||
export declare namespace create { | ||
var prototype: ArraySchema<any, any, any, any>; | ||
} | ||
export default class ArraySchema<T extends AnySchema, C extends AnyObject = AnyObject, TIn extends Maybe<TypeOf<T>[]> = TypeOf<T>[] | undefined, TOut extends Maybe<Asserts<T>[]> = Asserts<T>[] | Optionals<TIn>> extends BaseSchema<TIn, C, TOut> { | ||
export default class ArraySchema<T extends AnySchema | Lazy<any, any>, C extends AnyObject = AnyObject, TIn extends Maybe<TypeOf<T>[]> = TypeOf<T>[] | undefined, TOut extends Maybe<Asserts<T>[]> = Asserts<T>[] | Optionals<TIn>> extends BaseSchema<TIn, C, TOut> { | ||
innerType?: T; | ||
@@ -36,3 +37,3 @@ constructor(type?: T); | ||
} | ||
export interface DefinedArraySchema<T extends AnySchema, TContext extends AnyObject, TIn extends Maybe<TypeOf<T>[]>> extends ArraySchema<T, TContext, TIn, Asserts<T>[] | Preserve<TIn, null>> { | ||
export interface DefinedArraySchema<T extends AnySchema | Lazy<any, any>, TContext extends AnyObject, TIn extends Maybe<TypeOf<T>[]>> extends ArraySchema<T, TContext, TIn, Asserts<T>[] | Preserve<TIn, null>> { | ||
default<D extends Maybe<TIn>>(def: Thunk<D>): If<D, DefinedArraySchema<T, TContext, TIn | undefined>, DefinedArraySchema<T, TContext, Defined<TIn>>>; | ||
@@ -46,3 +47,3 @@ defined(msg?: MixedLocale['defined']): this; | ||
} | ||
export interface RequiredArraySchema<T extends AnySchema, TContext extends AnyObject, TIn extends Maybe<TypeOf<T>[]>> extends ArraySchema<T, TContext, TIn, Asserts<T>[]> { | ||
export interface RequiredArraySchema<T extends AnySchema | Lazy<any, any>, TContext extends AnyObject, TIn extends Maybe<TypeOf<T>[]>> extends ArraySchema<T, TContext, TIn, Asserts<T>[]> { | ||
default<D extends Maybe<TIn>>(def: Thunk<D>): If<D, RequiredArraySchema<T, TContext, TIn | undefined>, RequiredArraySchema<T, TContext, Defined<TIn>>>; | ||
@@ -56,3 +57,3 @@ defined(msg?: MixedLocale['defined']): DefinedArraySchema<T, TContext, TIn>; | ||
} | ||
export interface OptionalArraySchema<T extends AnySchema, TContext extends AnyObject = AnyObject, TIn extends Maybe<TypeOf<T>[]> = TypeOf<T>[] | undefined> extends ArraySchema<T, TContext, TIn> { | ||
export interface OptionalArraySchema<T extends AnySchema | Lazy<any, any>, TContext extends AnyObject = AnyObject, TIn extends Maybe<TypeOf<T>[]> = TypeOf<T>[] | undefined> extends ArraySchema<T, TContext, TIn> { | ||
default<D extends Maybe<TIn>>(def: Thunk<D>): If<D, ArraySchema<T, TContext, TIn | undefined>, ArraySchema<T, TContext, Defined<TIn>>>; | ||
@@ -59,0 +60,0 @@ defined(msg?: MixedLocale['defined']): DefinedArraySchema<T, TContext, TIn>; |
@@ -120,4 +120,3 @@ "use strict"; | ||
tests[idx] = (_, cb) => innerType.validate(item, innerOptions, // @ts-expect-error | ||
cb); | ||
tests[idx] = (_, cb) => innerType.validate(item, innerOptions, cb); | ||
} | ||
@@ -145,3 +144,4 @@ | ||
next.innerType = this.innerType; | ||
if (schema.innerType) next.innerType = next.innerType ? next.innerType.concat(schema.innerType) : schema.innerType; | ||
if (schema.innerType) next.innerType = next.innerType ? // @ts-expect-error Lazy doesn't have concat() | ||
next.innerType.concat(schema.innerType) : schema.innerType; | ||
return next; | ||
@@ -148,0 +148,0 @@ } |
@@ -22,2 +22,3 @@ import MixedSchema, { create as mixedCreate } from './mixed'; | ||
}> : T extends Array<infer E> ? ArraySchema<SchemaOf<E>> : BaseSchema<Maybe<T>, AnyObject, T>; | ||
export declare type AnyObjectSchema = ObjectSchema<any, any, any>; | ||
export type { SchemaOf, TypeOf, Asserts, Asserts as InferType, AnySchema }; | ||
@@ -24,0 +25,0 @@ 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, }; |
{ | ||
"name": "yup", | ||
"version": "0.32.1", | ||
"version": "0.32.2", | ||
"description": "Dead simple Object schema validation", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -805,3 +805,3 @@ # Yup | ||
module.exports = function (formats = 'MMM dd, yyyy') { | ||
return date().transform(function (value, originalvalue) { | ||
return date().transform(function (value, originalValue) { | ||
// check to see if the previous transform already parsed the date | ||
@@ -1187,3 +1187,3 @@ if (this.isType(value)) return value; | ||
const nameAndAge = person.omit('color']); | ||
const nameAndAge = person.omit(['color']); | ||
nameAndAge.getDefault(); // => { age: 30, name: 'pat'} | ||
@@ -1190,0 +1190,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
308924
5957