Comparing version 0.32.8 to 0.32.9
@@ -0,1 +1,20 @@ | ||
## [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 +21,0 @@ |
@@ -35,2 +35,6 @@ import { MixedLocale } from './locale'; | ||
describe(): SchemaInnerTypeDescription; | ||
nullable(isNullable?: true): ArraySchema<T, C, TIn | null>; | ||
nullable(isNullable: false): ArraySchema<T, C, Exclude<TIn, null>>; | ||
defined(): DefinedArraySchema<T, C, TIn>; | ||
required(msg?: MixedLocale['required']): RequiredArraySchema<T, C, TIn>; | ||
} | ||
@@ -37,0 +41,0 @@ 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>> { |
@@ -132,3 +132,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); } | ||
// FIXME: this should return a new instance of array without the default to be | ||
var next = this.clone(); | ||
let next = this.clone(); | ||
if (!isSchema(schema)) throw new TypeError('`array.of()` sub-schema must be a valid yup schema not: ' + printValue(schema)); // FIXME(ts): | ||
@@ -210,2 +210,14 @@ | ||
nullable(isNullable = true) { | ||
return super.nullable(isNullable); | ||
} | ||
defined() { | ||
return super.defined(); | ||
} | ||
required(msg) { | ||
return super.required(msg); | ||
} | ||
} | ||
@@ -212,0 +224,0 @@ create.prototype = ArraySchema.prototype; // |
@@ -9,3 +9,3 @@ import MixedSchema, { create as mixedCreate } from './mixed'; | ||
import { create as refCreate } from './Reference'; | ||
import { create as lazyCreate } from './Lazy'; | ||
import Lazy, { create as lazyCreate } from './Lazy'; | ||
import ValidationError from './ValidationError'; | ||
@@ -21,5 +21,6 @@ import reach from './util/reach'; | ||
declare type ObjectSchemaOf<T extends AnyObject> = ObjectSchema<{ | ||
[k in keyof T]-?: T[k] extends AnyObject ? ObjectSchemaOf<T[k]> : T[k] extends Array<infer E> ? ArraySchema<SchemaOf<E>> : BaseSchema<Maybe<T[k]>, AnyObject, T[k]>; | ||
[k in keyof T]-?: T[k] extends Array<infer E> ? ArraySchema<SchemaOf<E> | Lazy<SchemaOf<E>>> : T[k] extends AnyObject ? // we can't use ObjectSchema<{ []: SchemaOf<T[k]> }> b/c TS produces a union of two schema | ||
ObjectSchemaOf<T[k]> | ObjectSchemaOf<Lazy<T[k]>> : BaseSchema<Maybe<T[k]>, AnyObject, T[k]>; | ||
}>; | ||
declare type SchemaOf<T> = T extends AnyObject ? ObjectSchemaOf<T> : T extends Array<infer E> ? ArraySchema<SchemaOf<E>> : BaseSchema<Maybe<T>, AnyObject, T>; | ||
declare type SchemaOf<T> = T extends Array<infer E> ? ArraySchema<SchemaOf<E> | Lazy<SchemaOf<E>>> : T extends AnyObject ? ObjectSchemaOf<T> : BaseSchema<Maybe<T>, AnyObject, T>; | ||
export declare type AnyObjectSchema = ObjectSchema<any, any, any, any>; | ||
@@ -26,0 +27,0 @@ export type { SchemaOf, TypeOf, Asserts, Asserts as InferType, AnySchema }; |
@@ -5,3 +5,3 @@ import type { MixedLocale } from './locale'; | ||
import BaseSchema from './schema'; | ||
declare class MixedSchema<TType = any, TContext = AnyObject, TOut = TType> extends BaseSchema<TType, TContext, TOut> { | ||
export declare class MixedSchema<TType = any, TContext = AnyObject, TOut = TType> extends BaseSchema<TType, TContext, TOut> { | ||
default<TNextDefault extends Maybe<TType>>(def: TNextDefault | (() => TNextDefault)): TNextDefault extends undefined ? MixedSchema<TType | undefined, TContext> : MixedSchema<Defined<TType>, TContext>; | ||
@@ -8,0 +8,0 @@ concat(schema: this): this; |
@@ -212,3 +212,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); } | ||
return next.withMutation(next => next.shape(nextFields)); | ||
return next.withMutation(() => next.shape(nextFields)); | ||
} | ||
@@ -278,3 +278,3 @@ | ||
return next.withMutation(next => next.shape(fields)); | ||
return next.withMutation(() => next.shape(fields)); | ||
} | ||
@@ -281,0 +281,0 @@ |
@@ -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; |
@@ -33,4 +33,2 @@ 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); } | ||
recursive: true, | ||
label: undefined, | ||
meta: undefined, | ||
nullable: false, | ||
@@ -37,0 +35,0 @@ presence: 'optional' |
@@ -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; |
@@ -35,2 +35,6 @@ import { MixedLocale } from './locale'; | ||
describe(): SchemaInnerTypeDescription; | ||
nullable(isNullable?: true): ArraySchema<T, C, TIn | null>; | ||
nullable(isNullable: false): ArraySchema<T, C, Exclude<TIn, null>>; | ||
defined(): DefinedArraySchema<T, C, TIn>; | ||
required(msg?: MixedLocale['required']): RequiredArraySchema<T, C, TIn>; | ||
} | ||
@@ -37,0 +41,0 @@ 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>> { |
@@ -150,3 +150,3 @@ "use strict"; | ||
// FIXME: this should return a new instance of array without the default to be | ||
var next = this.clone(); | ||
let next = this.clone(); | ||
if (!(0, _isSchema.default)(schema)) throw new TypeError('`array.of()` sub-schema must be a valid yup schema not: ' + (0, _printValue.default)(schema)); // FIXME(ts): | ||
@@ -228,2 +228,14 @@ | ||
nullable(isNullable = true) { | ||
return super.nullable(isNullable); | ||
} | ||
defined() { | ||
return super.defined(); | ||
} | ||
required(msg) { | ||
return super.required(msg); | ||
} | ||
} | ||
@@ -230,0 +242,0 @@ |
@@ -9,3 +9,3 @@ import MixedSchema, { create as mixedCreate } from './mixed'; | ||
import { create as refCreate } from './Reference'; | ||
import { create as lazyCreate } from './Lazy'; | ||
import Lazy, { create as lazyCreate } from './Lazy'; | ||
import ValidationError from './ValidationError'; | ||
@@ -21,5 +21,6 @@ import reach from './util/reach'; | ||
declare type ObjectSchemaOf<T extends AnyObject> = ObjectSchema<{ | ||
[k in keyof T]-?: T[k] extends AnyObject ? ObjectSchemaOf<T[k]> : T[k] extends Array<infer E> ? ArraySchema<SchemaOf<E>> : BaseSchema<Maybe<T[k]>, AnyObject, T[k]>; | ||
[k in keyof T]-?: T[k] extends Array<infer E> ? ArraySchema<SchemaOf<E> | Lazy<SchemaOf<E>>> : T[k] extends AnyObject ? // we can't use ObjectSchema<{ []: SchemaOf<T[k]> }> b/c TS produces a union of two schema | ||
ObjectSchemaOf<T[k]> | ObjectSchemaOf<Lazy<T[k]>> : BaseSchema<Maybe<T[k]>, AnyObject, T[k]>; | ||
}>; | ||
declare type SchemaOf<T> = T extends AnyObject ? ObjectSchemaOf<T> : T extends Array<infer E> ? ArraySchema<SchemaOf<E>> : BaseSchema<Maybe<T>, AnyObject, T>; | ||
declare type SchemaOf<T> = T extends Array<infer E> ? ArraySchema<SchemaOf<E> | Lazy<SchemaOf<E>>> : T extends AnyObject ? ObjectSchemaOf<T> : BaseSchema<Maybe<T>, AnyObject, T>; | ||
export declare type AnyObjectSchema = ObjectSchema<any, any, any, any>; | ||
@@ -26,0 +27,0 @@ export type { SchemaOf, TypeOf, Asserts, Asserts as InferType, AnySchema }; |
@@ -5,3 +5,3 @@ import type { MixedLocale } from './locale'; | ||
import BaseSchema from './schema'; | ||
declare class MixedSchema<TType = any, TContext = AnyObject, TOut = TType> extends BaseSchema<TType, TContext, TOut> { | ||
export declare class MixedSchema<TType = any, TContext = AnyObject, TOut = TType> extends BaseSchema<TType, TContext, TOut> { | ||
default<TNextDefault extends Maybe<TType>>(def: TNextDefault | (() => TNextDefault)): TNextDefault extends undefined ? MixedSchema<TType | undefined, TContext> : MixedSchema<Defined<TType>, TContext>; | ||
@@ -8,0 +8,0 @@ concat(schema: this): this; |
@@ -234,3 +234,3 @@ "use strict"; | ||
return next.withMutation(next => next.shape(nextFields)); | ||
return next.withMutation(() => next.shape(nextFields)); | ||
} | ||
@@ -300,3 +300,3 @@ | ||
return next.withMutation(next => next.shape(fields)); | ||
return next.withMutation(() => next.shape(fields)); | ||
} | ||
@@ -303,0 +303,0 @@ |
@@ -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; |
@@ -52,4 +52,2 @@ "use strict"; | ||
recursive: true, | ||
label: undefined, | ||
meta: undefined, | ||
nullable: false, | ||
@@ -56,0 +54,0 @@ presence: 'optional' |
@@ -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; |
{ | ||
"name": "yup", | ||
"version": "0.32.8", | ||
"version": "0.32.9", | ||
"description": "Dead simple Object schema validation", | ||
@@ -114,3 +114,3 @@ "main": "lib/index.js", | ||
"lodash": "^4.17.20", | ||
"lodash-es": "^4.17.11", | ||
"lodash-es": "^4.17.15", | ||
"nanoclone": "^0.2.1", | ||
@@ -117,0 +117,0 @@ "property-expr": "^2.0.4", |
@@ -415,3 +415,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)) | ||
@@ -546,3 +546,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. | ||
@@ -549,0 +549,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
313340
6001
Updatedlodash-es@^4.17.15