Skip to main content

Class: ArraySchema<T, C, TIn, TOut>

yup.ArraySchema

Type parameters​

NameType
Textends AnySchema | Lazy<any, any>
Cextends AnyObject = AnyObject
TInextends Maybe<TypeOf<T>[]> = TypeOf<T>[] | undefined
TOutextends Maybe<Asserts<T>[]> = Asserts<T>[] | Optionals<TIn>

Hierarchy​

Constructors​

constructor​

• new ArraySchema<T, C, TIn, TOut>(type?)

Type parameters​

NameType
Textends AnySchema<any, any, any> | Lazy<any, any>
Cextends AnyObject = AnyObject
TInextends Maybe<TypeOf<T>[]> = undefined | TypeOf<T>[]
TOutextends Maybe<Asserts<T>[]> = Asserts<T>[] | Extract<TIn, undefined | null>

Parameters​

NameType
type?T

Overrides​

BaseSchema.constructor

Properties​

__inputType​

• Readonly __inputType: TIn

Inherited from​

BaseSchema.__inputType


__isYupSchema__​

• Readonly __isYupSchema__: boolean

Inherited from​

BaseSchema.isYupSchema


__outputType​

• Readonly __outputType: TOut

Inherited from​

BaseSchema.__outputType


_blacklist​

• Protected _blacklist: default

Inherited from​

BaseSchema._blacklist


_whitelist​

• Protected _whitelist: default

Inherited from​

BaseSchema._whitelist


deps​

• Readonly deps: readonly string[]

Inherited from​

BaseSchema.deps


equals​

• equals: <U>(enums: (default<unknown> | Maybe<U>)[], message?: Message<{ values: any }>) => BaseSchema<any, AnyObject, any>

Type declaration​

â–¸ <U>(enums, message?): BaseSchema<any, AnyObject, any>

Type parameters​
NameType
Uextends any
Parameters​
NameType
enums(default<unknown> | Maybe<U>)[]
message?Message<{ values: any }>
Returns​

BaseSchema<any, AnyObject, any>

Inherited from​

BaseSchema.equals


exclusiveTests​

• Protected exclusiveTests: Record<string, boolean>

Inherited from​

BaseSchema.exclusiveTests


innerType​

• Optional innerType: T


is​

• is: <U>(enums: (default<unknown> | Maybe<U>)[], message?: Message<{ values: any }>) => BaseSchema<any, AnyObject, any>

Type declaration​

â–¸ <U>(enums, message?): BaseSchema<any, AnyObject, any>

Type parameters​
NameType
Uextends any
Parameters​
NameType
enums(default<unknown> | Maybe<U>)[]
message?Message<{ values: any }>
Returns​

BaseSchema<any, AnyObject, any>

Inherited from​

BaseSchema.is


nope​

• nope: <U>(enums: (default<unknown> | Maybe<U>)[], message?: Message<{ values: any }>) => BaseSchema<any, AnyObject, any>

Type declaration​

â–¸ <U>(enums, message?): BaseSchema<any, AnyObject, any>

Type parameters​
NameType
Uextends any
Parameters​
NameType
enums(default<unknown> | Maybe<U>)[]
message?Message<{ values: any }>
Returns​

BaseSchema<any, AnyObject, any>

Inherited from​

BaseSchema.nope


not​

• not: <U>(enums: (default<unknown> | Maybe<U>)[], message?: Message<{ values: any }>) => BaseSchema<any, AnyObject, any>

Type declaration​

â–¸ <U>(enums, message?): BaseSchema<any, AnyObject, any>

Type parameters​
NameType
Uextends any
Parameters​
NameType
enums(default<unknown> | Maybe<U>)[]
message?Message<{ values: any }>
Returns​

BaseSchema<any, AnyObject, any>

Inherited from​

BaseSchema.not


spec​

• spec: SchemaSpec<any>

Inherited from​

BaseSchema.spec


tests​

• tests: Test[]

Inherited from​

BaseSchema.tests


transforms​

• transforms: TransformFunction<AnySchema<any, any, any>>[]

Inherited from​

BaseSchema.transforms


type​

• Readonly type: string

Inherited from​

BaseSchema.type

Accessors​

_subType​

• Private get _subType(): any

Returns​

any


_type​

• get _type(): string

Returns​

string

Inherited from​

BaseSchema._type

Methods​

_cast​

â–¸ Protected _cast(_value, _opts): any

Parameters​

NameType
_valueany
_optsInternalOptions<C>

Returns​

any

Overrides​

BaseSchema._cast


_getDefault​

â–¸ Protected _getDefault(): any

Returns​

any

Inherited from​

BaseSchema._getDefault


_isPresent​

â–¸ Protected _isPresent(value): boolean

Parameters​

NameType
valueunknown

Returns​

boolean

Inherited from​

BaseSchema._isPresent


_typeCheck​

â–¸ Protected _typeCheck(v): v is NonNullable<TIn>

Parameters​

NameType
vany

Returns​

v is NonNullable<TIn>

Overrides​

BaseSchema._typeCheck


_validate​

â–¸ Protected _validate(_value, options, callback): void

Parameters​

NameType
_valueany
optionsundefined | InternalOptions<C>
callbackCallback<any>

Returns​

void

Overrides​

BaseSchema._validate


cast​

â–¸ cast(value, options?): TIn

Parameters​

NameType
valueany
options?CastOptions<C>

Returns​

TIn

Inherited from​

BaseSchema.cast


clone​

â–¸ clone(spec?): ArraySchema<T, C, TIn, TOut>

Parameters​

NameType
spec?SchemaSpec<any>

Returns​

ArraySchema<T, C, TIn, TOut>

Overrides​

BaseSchema.clone


compact​

â–¸ compact(rejector?): ArraySchema<T, C, TIn, TOut>

Parameters​

NameType
rejector?RejectorFn

Returns​

ArraySchema<T, C, TIn, TOut>


concat​

â–¸ concat<TOther>(schema): TOther

Type parameters​

NameType
TOtherextends ArraySchema<any, any, any, any, TOther>

Parameters​

NameType
schemaTOther

Returns​

TOther

Overrides​

BaseSchema.concat

â–¸ concat(schema): any

Parameters​

NameType
schemaany

Returns​

any

Overrides​

BaseSchema.concat


default​

â–¸ default(def): any

Parameters​

NameType
defany

Returns​

any

Inherited from​

BaseSchema.default


defined​

â–¸ defined(): DefinedArraySchema<T, C, TIn>

Returns​

DefinedArraySchema<T, C, TIn>

Overrides​

BaseSchema.defined


describe​

â–¸ describe(): SchemaInnerTypeDescription

Returns​

SchemaInnerTypeDescription

Overrides​

BaseSchema.describe


ensure​

â–¸ ensure(): RequiredArraySchema<T, C, TIn>

Returns​

RequiredArraySchema<T, C, TIn>


getDefault​

â–¸ getDefault(options?): TIn

Parameters​

NameType
options?ResolveOptions<any>

Returns​

TIn

Inherited from​

BaseSchema.getDefault


isType​

â–¸ isType(v): boolean

Parameters​

NameType
vany

Returns​

boolean

Inherited from​

BaseSchema.isType


isValid​

â–¸ isValid(value, options?): Promise<boolean>

Parameters​

NameType
valueany
options?ValidateOptions<C>

Returns​

Promise<boolean>

Inherited from​

BaseSchema.isValid


isValidSync​

â–¸ isValidSync(value, options?): value is TOut

Parameters​

NameType
valueany
options?ValidateOptions<C>

Returns​

value is TOut

Inherited from​

BaseSchema.isValidSync


label​

â–¸ label(label): ArraySchema<T, C, TIn, TOut>

Parameters​

NameType
labelstring

Returns​

ArraySchema<T, C, TIn, TOut>

Inherited from​

BaseSchema.label


length​

â–¸ length(length, message?): ArraySchema<T, C, TIn, TOut>

Parameters​

NameType
lengthnumber | default<number>
message?Message<{ length: number }>

Returns​

ArraySchema<T, C, TIn, TOut>


max​

â–¸ max(max, message?): ArraySchema<T, C, TIn, TOut>

Parameters​

NameType
maxnumber | default<number>
message?Message<{ max: number }>

Returns​

ArraySchema<T, C, TIn, TOut>


meta​

â–¸ meta(): undefined | Record<string, unknown>

Returns​

undefined | Record<string, unknown>

Inherited from​

BaseSchema.meta

â–¸ meta(obj): ArraySchema<T, C, TIn, TOut>

Parameters​

NameType
objRecord<string, unknown>

Returns​

ArraySchema<T, C, TIn, TOut>

Inherited from​

BaseSchema.meta


min​

â–¸ min(min, message?): ArraySchema<T, C, TIn, TOut>

Parameters​

NameType
minnumber | default<number>
message?Message<{ min: number }>

Returns​

ArraySchema<T, C, TIn, TOut>


notOneOf​

â–¸ notOneOf<U>(enums, message?): ArraySchema<T, C, TIn, TOut>

Type parameters​

NameType
Uextends Maybe<TypeOf<T>[]>

Parameters​

NameType
enums(default<unknown> | Maybe<U>)[]
message?Message<{ values: any }>

Returns​

ArraySchema<T, C, TIn, TOut>

Inherited from​

BaseSchema.notOneOf


notRequired​

â–¸ notRequired(): any

Returns​

any

Inherited from​

BaseSchema.notRequired


nullable​

â–¸ nullable(isNullable?): ArraySchema<T, C, null | TIn, null | Asserts<T>[] | Extract<TIn, undefined | null>>

Parameters​

NameType
isNullable?true

Returns​

ArraySchema<T, C, null | TIn, null | Asserts<T>[] | Extract<TIn, undefined | null>>

Overrides​

BaseSchema.nullable

â–¸ nullable(isNullable): ArraySchema<T, C, Exclude<TIn, null>, Asserts<T>[] | Extract<Exclude<TIn, null>, undefined | null>>

Parameters​

NameType
isNullablefalse

Returns​

ArraySchema<T, C, Exclude<TIn, null>, Asserts<T>[] | Extract<Exclude<TIn, null>, undefined | null>>

Overrides​

BaseSchema.nullable


of​

â–¸ of<TInner>(schema): ArraySchema<TInner, AnyObject, undefined | TypeOf<TInner>[], undefined | Asserts<TInner>[]>

Type parameters​

NameType
TInnerextends BaseSchema<any, any, any, TInner>

Parameters​

NameType
schemaTInner

Returns​

ArraySchema<TInner, AnyObject, undefined | TypeOf<TInner>[], undefined | Asserts<TInner>[]>


oneOf​

â–¸ oneOf<U>(enums, message?): ArraySchema<T, C, TIn, TOut>

Type parameters​

NameType
Uextends Maybe<TypeOf<T>[]>

Parameters​

NameType
enums(default<unknown> | Maybe<U>)[]
message?Message<{ values: any }>

Returns​

ArraySchema<T, C, TIn, TOut>

Inherited from​

BaseSchema.oneOf


optional​

â–¸ optional(): any

Returns​

any

Inherited from​

BaseSchema.optional


required​

â–¸ required(msg?): RequiredArraySchema<T, C, TIn>

Parameters​

NameType
msg?Message<{}>

Returns​

RequiredArraySchema<T, C, TIn>

Overrides​

BaseSchema.required


resolve​

â–¸ resolve(options): ArraySchema<T, C, TIn, TOut>

Parameters​

NameType
optionsResolveOptions<any>

Returns​

ArraySchema<T, C, TIn, TOut>

Inherited from​

BaseSchema.resolve


strict​

â–¸ strict(isStrict?): ArraySchema<T, C, TIn, TOut>

Parameters​

NameType
isStrict?boolean

Returns​

ArraySchema<T, C, TIn, TOut>

Inherited from​

BaseSchema.strict


strip​

â–¸ strip(strip?): ArraySchema<T, C, TIn, TOut>

Parameters​

NameType
strip?boolean

Returns​

ArraySchema<T, C, TIn, TOut>

Inherited from​

BaseSchema.strip


test​

â–¸ test(options): ArraySchema<T, C, TIn, TOut>

Adds a test function to the schema's queue of tests. tests can be exclusive or non-exclusive.

  • exclusive tests, will replace any existing tests of the same name.
  • non-exclusive: can be stacked

If a non-exclusive test is added to a schema with an exclusive test of the same name the exclusive test is removed and further tests of the same name will be stacked.

If an exclusive test is added to a schema with non-exclusive tests of the same name the previous tests are removed and further tests of the same name will replace each other.

Parameters​

NameType
optionsTestConfig<TIn, C>

Returns​

ArraySchema<T, C, TIn, TOut>

Inherited from​

BaseSchema.test

â–¸ test(test): ArraySchema<T, C, TIn, TOut>

Parameters​

NameType
testTestFunction<TIn, C>

Returns​

ArraySchema<T, C, TIn, TOut>

Inherited from​

BaseSchema.test

â–¸ test(name, test): ArraySchema<T, C, TIn, TOut>

Parameters​

NameType
namestring
testTestFunction<TIn, C>

Returns​

ArraySchema<T, C, TIn, TOut>

Inherited from​

BaseSchema.test

â–¸ test(name, message, test): ArraySchema<T, C, TIn, TOut>

Parameters​

NameType
namestring
messageMessage<{}>
testTestFunction<TIn, C>

Returns​

ArraySchema<T, C, TIn, TOut>

Inherited from​

BaseSchema.test


transform​

â–¸ transform(fn): ArraySchema<T, C, TIn, TOut>

Parameters​

NameType
fnTransformFunction<ArraySchema<T, C, TIn, TOut>>

Returns​

ArraySchema<T, C, TIn, TOut>

Inherited from​

BaseSchema.transform


typeError​

â–¸ typeError(message): ArraySchema<T, C, TIn, TOut>

Parameters​

NameType
messageMessage<{}>

Returns​

ArraySchema<T, C, TIn, TOut>

Inherited from​

BaseSchema.typeError


validate​

â–¸ validate(value, options?): Promise<TOut>

Parameters​

NameType
valueany
options?ValidateOptions<C>

Returns​

Promise<TOut>

Inherited from​

BaseSchema.validate


validateAt​

â–¸ validateAt(path, value, options?): Promise<TOut>

Parameters​

NameType
pathstring
valueany
options?ValidateOptions<C>

Returns​

Promise<TOut>

Inherited from​

BaseSchema.validateAt


validateSync​

â–¸ validateSync(value, options?): TOut

Parameters​

NameType
valueany
options?ValidateOptions<C>

Returns​

TOut

Inherited from​

BaseSchema.validateSync


validateSyncAt​

â–¸ validateSyncAt(path, value, options?): TOut

Parameters​

NameType
pathstring
valueany
options?ValidateOptions<C>

Returns​

TOut

Inherited from​

BaseSchema.validateSyncAt


when​

â–¸ when(options): ArraySchema<T, C, TIn, TOut>

Parameters​

NameType
optionsConditionOptions<ArraySchema<T, C, TIn, TOut>>

Returns​

ArraySchema<T, C, TIn, TOut>

Inherited from​

BaseSchema.when

â–¸ when(keys, options): ArraySchema<T, C, TIn, TOut>

Parameters​

NameType
keysstring | string[]
optionsConditionOptions<ArraySchema<T, C, TIn, TOut>>

Returns​

ArraySchema<T, C, TIn, TOut>

Inherited from​

BaseSchema.when


withMutation​

â–¸ withMutation<T>(fn): T

Type parameters​

Name
T

Parameters​

NameType
fn(schema: ArraySchema<T, C, TIn, TOut>) => T

Returns​

T

Inherited from​

BaseSchema.withMutation