Comparing version 1.0.0-alpha.4 to 1.0.0-beta.0
@@ -1,2 +0,2 @@ | ||
import type { AnyObject, InternalOptions, Callback, Message, Maybe } from './types'; | ||
import type { AnyObject, InternalOptions, Callback, Message, Maybe, Optionals } from './types'; | ||
import type Reference from './Reference'; | ||
@@ -6,17 +6,19 @@ import { Defined, Flags, NotNull, SetFlag, Thunk, ToggleDefault, ISchema, UnsetFlag, Concat } from './util/types'; | ||
import { ResolveOptions } from './Condition'; | ||
declare type InnerType<T> = T extends Array<infer I> ? I : never; | ||
export declare type RejectorFn = (value: any, index: number, array: readonly any[]) => boolean; | ||
export declare function create<C extends AnyObject = AnyObject, T = any>(type?: ISchema<T, C>): ArraySchema<T, C, undefined, "", T[] | undefined>; | ||
export declare function create<C extends AnyObject = AnyObject, T = any>(type?: ISchema<T, C>): ArraySchema<T[] | undefined, C, undefined, "">; | ||
export declare namespace create { | ||
var prototype: ArraySchema<any, any, any, any, any>; | ||
var prototype: ArraySchema<any, any, any, any>; | ||
} | ||
export default class ArraySchema<T, TContext, TDefault = undefined, TFlags extends Flags = '', TIn extends any[] | null | undefined = T[] | undefined> extends Schema<TIn, TContext, TDefault, TFlags> { | ||
innerType?: ISchema<T, TContext>; | ||
constructor(type?: ISchema<T, TContext>); | ||
private get _subType(); | ||
export default class ArraySchema<TIn extends any[] | null | undefined, TContext, TDefault = undefined, TFlags extends Flags = ''> extends Schema<TIn, TContext, TDefault, TFlags> { | ||
readonly innerType?: ISchema<InnerType<TIn>, TContext>; | ||
constructor(type?: ISchema<InnerType<TIn>, TContext>); | ||
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<IT, IC, ID, IF extends Flags, IIn extends Maybe<IT[]>>(schema: ArraySchema<IT, IC, ID, IF, IIn>): ArraySchema<Concat<T, IT>, TContext & IC, Extract<IF, 'd'> extends never ? TDefault : ID, TFlags | IF, Concat<TIn, IIn>>; | ||
/** Parse an input JSON string to an object */ | ||
json(): this; | ||
concat<IIn extends Maybe<any[]>, IC, ID, IF extends Flags>(schema: ArraySchema<IIn, IC, ID, IF>): ArraySchema<Concat<TIn, IIn>, TContext & IC, Extract<IF, 'd'> extends never ? TDefault : ID, TFlags | IF>; | ||
concat(schema: this): this; | ||
of<U>(schema: ISchema<U, TContext>): ArraySchema<U, TContext, TFlags>; | ||
of<U>(schema: ISchema<U, TContext>): ArraySchema<U[] | Optionals<TIn>, TContext, TFlags>; | ||
length(length: number | Reference<number>, message?: Message<{ | ||
@@ -31,16 +33,17 @@ length: number; | ||
}>): this; | ||
ensure(): ArraySchema<T, TContext, TIn, ToggleDefault<TFlags, TIn>, TIn>; | ||
ensure(): ArraySchema<TIn, TContext, TIn, ToggleDefault<TFlags, TIn>>; | ||
compact(rejector?: RejectorFn): this; | ||
describe(options?: ResolveOptions<TContext>): SchemaInnerTypeDescription; | ||
} | ||
export default interface ArraySchema<T, TContext, TDefault = undefined, TFlags extends Flags = '', TIn extends any[] | null | undefined = T[] | undefined> extends Schema<TIn, TContext, TDefault, TFlags> { | ||
default<D extends Maybe<TIn>>(def: Thunk<D>): ArraySchema<T, TContext, D, ToggleDefault<TFlags, D>, TIn>; | ||
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'>>; | ||
export default interface ArraySchema<TIn extends any[] | null | undefined, TContext, TDefault = undefined, TFlags extends Flags = ''> extends Schema<TIn, TContext, TDefault, TFlags> { | ||
default<D extends Maybe<TIn>>(def: Thunk<D>): ArraySchema<TIn, TContext, D, ToggleDefault<TFlags, D>>; | ||
defined(msg?: Message): ArraySchema<Defined<TIn>, TContext, TDefault, TFlags>; | ||
optional(): ArraySchema<TIn | undefined, TContext, TDefault, TFlags>; | ||
required(msg?: Message): ArraySchema<NonNullable<TIn>, TContext, TDefault, TFlags>; | ||
notRequired(): ArraySchema<Maybe<TIn>, TContext, TDefault, TFlags>; | ||
nullable(msg?: Message): ArraySchema<TIn | null, TContext, TDefault, TFlags>; | ||
nonNullable(): ArraySchema<NotNull<TIn>, TContext, TDefault, TFlags>; | ||
strip(enabled: false): ArraySchema<TIn, TContext, TDefault, UnsetFlag<TFlags, 's'>>; | ||
strip(enabled?: true): ArraySchema<TIn, TContext, TDefault, SetFlag<TFlags, 's'>>; | ||
} | ||
export {}; |
@@ -10,2 +10,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); } | ||
import Schema from './schema'; | ||
import parseJson from 'parse-json'; | ||
export function create(type) { | ||
@@ -23,33 +24,16 @@ return new ArraySchema(type); | ||
}); // `undefined` specifically means uninitialized, as opposed to | ||
// "no subtype" | ||
}); // `undefined` specifically means uninitialized, as opposed to "no subtype" | ||
this.innerType = void 0; | ||
this.innerType = type; | ||
this.withMutation(() => { | ||
this.transform((values, _, ctx) => { | ||
if (!ctx.spec.coarce) return values; | ||
if (typeof values === 'string') { | ||
try { | ||
values = JSON.parse(values); | ||
} catch (err) { | ||
values = null; | ||
} | ||
} | ||
return ctx.isType(values) ? values : null; | ||
}); | ||
}); | ||
} | ||
get _subType() { | ||
return this.innerType; | ||
} | ||
_cast(_value, _opts) { | ||
const value = super._cast(_value, _opts); //should ignore nulls here | ||
const value = super._cast(_value, _opts); // should ignore nulls here | ||
if (!this._typeCheck(value) || !this.innerType) return value; | ||
if (!this._typeCheck(value) || !this.innerType) { | ||
return value; | ||
} | ||
let isChanged = false; | ||
@@ -126,12 +110,21 @@ const castArray = value.map((v, idx) => { | ||
clone(spec) { | ||
const next = super.clone(spec); | ||
const next = super.clone(spec); // @ts-expect-error readonly | ||
next.innerType = this.innerType; | ||
return next; | ||
} | ||
/** Parse an input JSON string to an object */ | ||
json() { | ||
return this.transform(parseJson); | ||
} | ||
concat(schema) { | ||
let next = super.concat(schema); | ||
let next = super.concat(schema); // @ts-expect-error readonly | ||
next.innerType = this.innerType; | ||
if (schema.innerType) next.innerType = next.innerType ? // @ts-expect-error Lazy doesn't have concat and will break | ||
next.innerType.concat(schema.innerType) : schema.innerType; | ||
if (schema.innerType) // @ts-expect-error readonly | ||
next.innerType = next.innerType ? // @ts-expect-error Lazy doesn't have concat and will break | ||
next.innerType.concat(schema.innerType) : schema.innerType; | ||
return next; | ||
@@ -143,3 +136,3 @@ } | ||
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): | ||
if (!isSchema(schema)) throw new TypeError('`array.of()` sub-schema must be a valid yup schema not: ' + printValue(schema)); // @ts-expect-error readonly | ||
@@ -199,5 +192,4 @@ next.innerType = schema; | ||
}); | ||
} // ArraySchema<T, TContext, T[], SetFlag<TFlags, 'd'>, NonNullable<TIn>> | ||
} | ||
ensure() { | ||
@@ -204,0 +196,0 @@ return this.default(() => []).transform((val, original) => { |
@@ -51,2 +51,4 @@ import { Flags, ISchema, SetFlag, ToggleDefault, UnsetFlag } from './util/types'; | ||
from(from: string, to: keyof TIn, alias?: boolean): this; | ||
/** Parse an input JSON string to an object */ | ||
json(): this; | ||
noUnknown(message?: Message): this; | ||
@@ -53,0 +55,0 @@ noUnknown(noAllow: boolean, message?: Message): this; |
@@ -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); } | ||
import Schema from './schema'; | ||
import parseJson from './util/parseJson'; | ||
@@ -48,15 +49,2 @@ const deepHas = (obj, p) => { | ||
this.withMutation(() => { | ||
this.transform((value, _raw, ctx) => { | ||
if (typeof value === 'string') { | ||
try { | ||
value = JSON.parse(value); | ||
} catch (err) { | ||
value = null; | ||
} | ||
} | ||
if (ctx.isType(value)) return value; | ||
return null; | ||
}); | ||
if (spec) { | ||
@@ -318,3 +306,9 @@ this.shape(spec); | ||
} | ||
/** Parse an input JSON string to an object */ | ||
json() { | ||
return this.transform(parseJson); | ||
} | ||
noUnknown(noAllow = true, message = locale.noUnknown) { | ||
@@ -321,0 +315,0 @@ if (typeof noAllow !== 'boolean') { |
@@ -1,2 +0,2 @@ | ||
import type { AnyObject, InternalOptions, Callback, Message, Maybe } from './types'; | ||
import type { AnyObject, InternalOptions, Callback, Message, Maybe, Optionals } from './types'; | ||
import type Reference from './Reference'; | ||
@@ -6,17 +6,19 @@ import { Defined, Flags, NotNull, SetFlag, Thunk, ToggleDefault, ISchema, UnsetFlag, Concat } from './util/types'; | ||
import { ResolveOptions } from './Condition'; | ||
declare type InnerType<T> = T extends Array<infer I> ? I : never; | ||
export declare type RejectorFn = (value: any, index: number, array: readonly any[]) => boolean; | ||
export declare function create<C extends AnyObject = AnyObject, T = any>(type?: ISchema<T, C>): ArraySchema<T, C, undefined, "", T[] | undefined>; | ||
export declare function create<C extends AnyObject = AnyObject, T = any>(type?: ISchema<T, C>): ArraySchema<T[] | undefined, C, undefined, "">; | ||
export declare namespace create { | ||
var prototype: ArraySchema<any, any, any, any, any>; | ||
var prototype: ArraySchema<any, any, any, any>; | ||
} | ||
export default class ArraySchema<T, TContext, TDefault = undefined, TFlags extends Flags = '', TIn extends any[] | null | undefined = T[] | undefined> extends Schema<TIn, TContext, TDefault, TFlags> { | ||
innerType?: ISchema<T, TContext>; | ||
constructor(type?: ISchema<T, TContext>); | ||
private get _subType(); | ||
export default class ArraySchema<TIn extends any[] | null | undefined, TContext, TDefault = undefined, TFlags extends Flags = ''> extends Schema<TIn, TContext, TDefault, TFlags> { | ||
readonly innerType?: ISchema<InnerType<TIn>, TContext>; | ||
constructor(type?: ISchema<InnerType<TIn>, TContext>); | ||
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<IT, IC, ID, IF extends Flags, IIn extends Maybe<IT[]>>(schema: ArraySchema<IT, IC, ID, IF, IIn>): ArraySchema<Concat<T, IT>, TContext & IC, Extract<IF, 'd'> extends never ? TDefault : ID, TFlags | IF, Concat<TIn, IIn>>; | ||
/** Parse an input JSON string to an object */ | ||
json(): this; | ||
concat<IIn extends Maybe<any[]>, IC, ID, IF extends Flags>(schema: ArraySchema<IIn, IC, ID, IF>): ArraySchema<Concat<TIn, IIn>, TContext & IC, Extract<IF, 'd'> extends never ? TDefault : ID, TFlags | IF>; | ||
concat(schema: this): this; | ||
of<U>(schema: ISchema<U, TContext>): ArraySchema<U, TContext, TFlags>; | ||
of<U>(schema: ISchema<U, TContext>): ArraySchema<U[] | Optionals<TIn>, TContext, TFlags>; | ||
length(length: number | Reference<number>, message?: Message<{ | ||
@@ -31,16 +33,17 @@ length: number; | ||
}>): this; | ||
ensure(): ArraySchema<T, TContext, TIn, ToggleDefault<TFlags, TIn>, TIn>; | ||
ensure(): ArraySchema<TIn, TContext, TIn, ToggleDefault<TFlags, TIn>>; | ||
compact(rejector?: RejectorFn): this; | ||
describe(options?: ResolveOptions<TContext>): SchemaInnerTypeDescription; | ||
} | ||
export default interface ArraySchema<T, TContext, TDefault = undefined, TFlags extends Flags = '', TIn extends any[] | null | undefined = T[] | undefined> extends Schema<TIn, TContext, TDefault, TFlags> { | ||
default<D extends Maybe<TIn>>(def: Thunk<D>): ArraySchema<T, TContext, D, ToggleDefault<TFlags, D>, TIn>; | ||
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'>>; | ||
export default interface ArraySchema<TIn extends any[] | null | undefined, TContext, TDefault = undefined, TFlags extends Flags = ''> extends Schema<TIn, TContext, TDefault, TFlags> { | ||
default<D extends Maybe<TIn>>(def: Thunk<D>): ArraySchema<TIn, TContext, D, ToggleDefault<TFlags, D>>; | ||
defined(msg?: Message): ArraySchema<Defined<TIn>, TContext, TDefault, TFlags>; | ||
optional(): ArraySchema<TIn | undefined, TContext, TDefault, TFlags>; | ||
required(msg?: Message): ArraySchema<NonNullable<TIn>, TContext, TDefault, TFlags>; | ||
notRequired(): ArraySchema<Maybe<TIn>, TContext, TDefault, TFlags>; | ||
nullable(msg?: Message): ArraySchema<TIn | null, TContext, TDefault, TFlags>; | ||
nonNullable(): ArraySchema<NotNull<TIn>, TContext, TDefault, TFlags>; | ||
strip(enabled: false): ArraySchema<TIn, TContext, TDefault, UnsetFlag<TFlags, 's'>>; | ||
strip(enabled?: true): ArraySchema<TIn, TContext, TDefault, SetFlag<TFlags, 's'>>; | ||
} | ||
export {}; |
@@ -23,2 +23,4 @@ "use strict"; | ||
var _parseJson = _interopRequireDefault(require("parse-json")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -41,33 +43,16 @@ | ||
}); // `undefined` specifically means uninitialized, as opposed to | ||
// "no subtype" | ||
}); // `undefined` specifically means uninitialized, as opposed to "no subtype" | ||
this.innerType = void 0; | ||
this.innerType = type; | ||
this.withMutation(() => { | ||
this.transform((values, _, ctx) => { | ||
if (!ctx.spec.coarce) return values; | ||
if (typeof values === 'string') { | ||
try { | ||
values = JSON.parse(values); | ||
} catch (err) { | ||
values = null; | ||
} | ||
} | ||
return ctx.isType(values) ? values : null; | ||
}); | ||
}); | ||
} | ||
get _subType() { | ||
return this.innerType; | ||
} | ||
_cast(_value, _opts) { | ||
const value = super._cast(_value, _opts); //should ignore nulls here | ||
const value = super._cast(_value, _opts); // should ignore nulls here | ||
if (!this._typeCheck(value) || !this.innerType) return value; | ||
if (!this._typeCheck(value) || !this.innerType) { | ||
return value; | ||
} | ||
let isChanged = false; | ||
@@ -144,12 +129,21 @@ const castArray = value.map((v, idx) => { | ||
clone(spec) { | ||
const next = super.clone(spec); | ||
const next = super.clone(spec); // @ts-expect-error readonly | ||
next.innerType = this.innerType; | ||
return next; | ||
} | ||
/** Parse an input JSON string to an object */ | ||
json() { | ||
return this.transform(_parseJson.default); | ||
} | ||
concat(schema) { | ||
let next = super.concat(schema); | ||
let next = super.concat(schema); // @ts-expect-error readonly | ||
next.innerType = this.innerType; | ||
if (schema.innerType) next.innerType = next.innerType ? // @ts-expect-error Lazy doesn't have concat and will break | ||
next.innerType.concat(schema.innerType) : schema.innerType; | ||
if (schema.innerType) // @ts-expect-error readonly | ||
next.innerType = next.innerType ? // @ts-expect-error Lazy doesn't have concat and will break | ||
next.innerType.concat(schema.innerType) : schema.innerType; | ||
return next; | ||
@@ -161,3 +155,3 @@ } | ||
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): | ||
if (!(0, _isSchema.default)(schema)) throw new TypeError('`array.of()` sub-schema must be a valid yup schema not: ' + (0, _printValue.default)(schema)); // @ts-expect-error readonly | ||
@@ -217,5 +211,4 @@ next.innerType = schema; | ||
}); | ||
} // ArraySchema<T, TContext, T[], SetFlag<TFlags, 'd'>, NonNullable<TIn>> | ||
} | ||
ensure() { | ||
@@ -222,0 +215,0 @@ return this.default(() => []).transform((val, original) => { |
@@ -51,2 +51,4 @@ import { Flags, ISchema, SetFlag, ToggleDefault, UnsetFlag } from './util/types'; | ||
from(from: string, to: keyof TIn, alias?: boolean): this; | ||
/** Parse an input JSON string to an object */ | ||
json(): this; | ||
noUnknown(message?: Message): this; | ||
@@ -53,0 +55,0 @@ noUnknown(noAllow: boolean, message?: Message): this; |
@@ -25,2 +25,4 @@ "use strict"; | ||
var _parseJson = _interopRequireDefault(require("./util/parseJson")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -66,15 +68,2 @@ | ||
this.withMutation(() => { | ||
this.transform((value, _raw, ctx) => { | ||
if (typeof value === 'string') { | ||
try { | ||
value = JSON.parse(value); | ||
} catch (err) { | ||
value = null; | ||
} | ||
} | ||
if (ctx.isType(value)) return value; | ||
return null; | ||
}); | ||
if (spec) { | ||
@@ -336,3 +325,9 @@ this.shape(spec); | ||
} | ||
/** Parse an input JSON string to an object */ | ||
json() { | ||
return this.transform(_parseJson.default); | ||
} | ||
noUnknown(noAllow = true, message = _locale.object.noUnknown) { | ||
@@ -339,0 +334,0 @@ if (typeof noAllow !== 'boolean') { |
{ | ||
"name": "yup", | ||
"version": "1.0.0-alpha.4", | ||
"version": "1.0.0-beta.0", | ||
"description": "Dead simple Object schema validation", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -169,7 +169,8 @@ # Yup | ||
- [array](#array) | ||
- [`array.of(type: Schema): Schema`](#arrayoftype-schema-schema) | ||
- [`array.length(length: number | Ref, message?: string | function): Schema`](#arraylengthlength-number--ref-message-string--function-schema) | ||
- [`array.min(limit: number | Ref, message?: string | function): Schema`](#arrayminlimit-number--ref-message-string--function-schema) | ||
- [`array.max(limit: number | Ref, message?: string | function): Schema`](#arraymaxlimit-number--ref-message-string--function-schema) | ||
- [`array.ensure(): Schema`](#arrayensure-schema) | ||
- [`array.of(type: Schema): this`](#arrayoftype-schema-this) | ||
- [`array.json(): this`](#arrayjson-this) | ||
- [`array.length(length: number | Ref, message?: string | function): this`](#arraylengthlength-number--ref-message-string--function-this) | ||
- [`array.min(limit: number | Ref, message?: string | function): this`](#arrayminlimit-number--ref-message-string--function-this) | ||
- [`array.max(limit: number | Ref, message?: string | function): this`](#arraymaxlimit-number--ref-message-string--function-this) | ||
- [`array.ensure(): this`](#arrayensure-this) | ||
- [`array.compact(rejector: (value) => boolean): Schema`](#arraycompactrejector-value--boolean-schema) | ||
@@ -179,2 +180,3 @@ - [object](#object) | ||
- [`object.shape(fields: object, noSortEdges?: Array<[string, string]>): Schema`](#objectshapefields-object-nosortedges-arraystring-string-schema) | ||
- [`object.json(): this`](#objectjson-this) | ||
- [`object.concat(schemaB: ObjectSchema): ObjectSchema`](#objectconcatschemab-objectschema-objectschema) | ||
@@ -1425,3 +1427,3 @@ - [`object.pick(keys: string[]): Schema`](#objectpickkeys-string-schema) | ||
#### `array.of(type: Schema): Schema` | ||
#### `array.of(type: Schema): this` | ||
@@ -1431,15 +1433,19 @@ Specify the schema of array elements. `of()` is optional and when omitted the array schema will | ||
#### `array.length(length: number | Ref, message?: string | function): Schema` | ||
#### `array.json(): this` | ||
Attempt to parse input string values as JSON using [`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse). | ||
#### `array.length(length: number | Ref, message?: string | function): this` | ||
Set a specific length requirement for the array. The `${length}` interpolation can be used in the `message` argument. | ||
#### `array.min(limit: number | Ref, message?: string | function): Schema` | ||
#### `array.min(limit: number | Ref, message?: string | function): this` | ||
Set a minimum length limit for the array. The `${min}` interpolation can be used in the `message` argument. | ||
#### `array.max(limit: number | Ref, message?: string | function): Schema` | ||
#### `array.max(limit: number | Ref, message?: string | function): this` | ||
Set a maximum length limit for the array. The `${max}` interpolation can be used in the `message` argument. | ||
#### `array.ensure(): Schema` | ||
#### `array.ensure(): this` | ||
@@ -1483,6 +1489,4 @@ Ensures that the value is an array, by setting the default to `[]` and transforming `null` and `undefined` | ||
The default `cast` behavior for `object` is: [`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) | ||
object schema do not have any default transforms applied. | ||
Failed casts return: `null`; | ||
#### Object schema defaults | ||
@@ -1554,2 +1558,6 @@ | ||
#### `object.json(): this` | ||
Attempt to parse input string values as JSON using [`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse). | ||
#### `object.concat(schemaB: ObjectSchema): ObjectSchema` | ||
@@ -1556,0 +1564,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
331212
126
6241
1620