Class: BaseSchema<TCast, TContext, TOutput>
yup.BaseSchema
Type parameters​
Name | Type |
---|---|
TCast | any |
TContext | AnyObject |
TOutput | any |
Hierarchy​
BaseSchema
↳
BooleanSchema
↳
default
↳
default
↳
DateSchema
↳
ObjectSchema
↳
ArraySchema
Constructors​
constructor​
• new BaseSchema<TCast
, TContext
, TOutput
>(options?
)
Type parameters​
Name | Type |
---|---|
TCast | any |
TContext | AnyObject |
TOutput | any |
Parameters​
Name | Type |
---|---|
options? | SchemaOptions <any > |
Properties​
__inputType​
• Readonly
__inputType: TCast
__isYupSchema__​
• Readonly
__isYupSchema__: boolean
__outputType​
• Readonly
__outputType: TOutput
_blacklist​
• Protected
_blacklist: default
_blacklistError​
• Private
Optional
_blacklistError: any
_mutate​
• Private
Optional
_mutate: any
_typeError​
• Private
Optional
_typeError: any
_whitelist​
• Protected
_whitelist: default
_whitelistError​
• Private
Optional
_whitelistError: any
conditions​
• Private
conditions: any
deps​
• Readonly
deps: readonly string
[]
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​
Name | Type |
---|---|
U | extends any |
Parameters​
Name | Type |
---|---|
enums | (default <unknown > | Maybe <U >)[] |
message? | Message <{ values : any }> |
Returns​
BaseSchema
<any
, AnyObject
, any
>
exclusiveTests​
• Protected
exclusiveTests: Record
<string
, boolean
>
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​
Name | Type |
---|---|
U | extends any |
Parameters​
Name | Type |
---|---|
enums | (default <unknown > | Maybe <U >)[] |
message? | Message <{ values : any }> |
Returns​
BaseSchema
<any
, AnyObject
, any
>
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​
Name | Type |
---|---|
U | extends any |
Parameters​
Name | Type |
---|---|
enums | (default <unknown > | Maybe <U >)[] |
message? | Message <{ values : any }> |
Returns​
BaseSchema
<any
, AnyObject
, any
>
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​
Name | Type |
---|---|
U | extends any |
Parameters​
Name | Type |
---|---|
enums | (default <unknown > | Maybe <U >)[] |
message? | Message <{ values : any }> |
Returns​
BaseSchema
<any
, AnyObject
, any
>
spec​
• spec: SchemaSpec
<any
>
tests​
• tests: Test
[]
transforms​
• transforms: TransformFunction
<AnySchema
<any
, any
, any
>>[]
type​
• Readonly
type: string
Accessors​
_type​
• get
_type(): string
Returns​
string
Methods​
_cast​
â–¸ Protected
_cast(rawValue
, _options
): any
Parameters​
Name | Type |
---|---|
rawValue | any |
_options | CastOptions <TContext > |
Returns​
any
_getDefault​
â–¸ Protected
_getDefault(): any
Returns​
any
_isPresent​
â–¸ Protected
_isPresent(value
): boolean
Parameters​
Name | Type |
---|---|
value | unknown |
Returns​
boolean
_typeCheck​
â–¸ Protected
_typeCheck(_value
): _value is NonNullable<TCast>
Parameters​
Name | Type |
---|---|
_value | any |
Returns​
_value is NonNullable<TCast>
_validate​
â–¸ Protected
_validate(_value
, options
, cb
): void
Parameters​
Name | Type |
---|---|
_value | any |
options | undefined | InternalOptions <TContext > |
cb | Callback <any > |
Returns​
void
cast​
â–¸ cast(value
, options?
): TCast
Parameters​
Name | Type |
---|---|
value | any |
options? | CastOptions <TContext > |
Returns​
TCast
clone​
â–¸ clone(spec?
): BaseSchema
<TCast
, TContext
, TOutput
>
Parameters​
Name | Type |
---|---|
spec? | Partial <SchemaSpec <any >> |
Returns​
BaseSchema
<TCast
, TContext
, TOutput
>
concat​
â–¸ concat(schema
): BaseSchema
<TCast
, TContext
, TOutput
>
Parameters​
Name | Type |
---|---|
schema | BaseSchema <TCast , TContext , TOutput > |
Returns​
BaseSchema
<TCast
, TContext
, TOutput
>
â–¸ concat(schema
): AnySchema
<any
, any
, any
>
Parameters​
Name | Type |
---|---|
schema | AnySchema <any , any , any > |
Returns​
AnySchema
<any
, any
, any
>
default​
â–¸ default(def
): any
Parameters​
Name | Type |
---|---|
def | any |
Returns​
any
defined​
â–¸ defined(message?
): any
Parameters​
Name | Type |
---|---|
message? | Message <{}> |
Returns​
any
describe​
â–¸ describe(): SchemaDescription
Returns​
SchemaDescription
getDefault​
â–¸ getDefault(options?
): TCast
Parameters​
Name | Type |
---|---|
options? | ResolveOptions <any > |
Returns​
TCast
isType​
â–¸ isType(v
): boolean
Parameters​
Name | Type |
---|---|
v | any |
Returns​
boolean
isValid​
â–¸ isValid(value
, options?
): Promise
<boolean
>
Parameters​
Name | Type |
---|---|
value | any |
options? | ValidateOptions <TContext > |
Returns​
Promise
<boolean
>
isValidSync​
â–¸ isValidSync(value
, options?
): value is TOutput
Parameters​
Name | Type |
---|---|
value | any |
options? | ValidateOptions <TContext > |
Returns​
value is TOutput
label​
â–¸ label(label
): BaseSchema
<TCast
, TContext
, TOutput
>
Parameters​
Name | Type |
---|---|
label | string |
Returns​
BaseSchema
<TCast
, TContext
, TOutput
>
meta​
â–¸ meta(): undefined
| Record
<string
, unknown
>
Returns​
undefined
| Record
<string
, unknown
>
â–¸ meta(obj
): BaseSchema
<TCast
, TContext
, TOutput
>
Parameters​
Name | Type |
---|---|
obj | Record <string , unknown > |
Returns​
BaseSchema
<TCast
, TContext
, TOutput
>
notOneOf​
â–¸ notOneOf<U
>(enums
, message?
): BaseSchema
<TCast
, TContext
, TOutput
>
Type parameters​
Name |
---|
U |
Parameters​
Name | Type |
---|---|
enums | (default <unknown > | Maybe <U >)[] |
message? | Message <{ values : any }> |
Returns​
BaseSchema
<TCast
, TContext
, TOutput
>
notRequired​
â–¸ notRequired(): any
Returns​
any
nullable​
â–¸ nullable(isNullable?
): any
Parameters​
Name | Type |
---|---|
isNullable? | true |
Returns​
any
â–¸ nullable(isNullable
): any
Parameters​
Name | Type |
---|---|
isNullable | false |
Returns​
any
oneOf​
â–¸ oneOf<U
>(enums
, message?
): BaseSchema
<TCast
, TContext
, TOutput
>
Type parameters​
Name |
---|
U |
Parameters​
Name | Type |
---|---|
enums | (default <unknown > | Maybe <U >)[] |
message? | Message <{ values : any }> |
Returns​
BaseSchema
<TCast
, TContext
, TOutput
>
optional​
â–¸ optional(): any
Returns​
any
required​
â–¸ required(message?
): any
Parameters​
Name | Type |
---|---|
message? | Message <{}> |
Returns​
any
resolve​
â–¸ resolve(options
): BaseSchema
<TCast
, TContext
, TOutput
>
Parameters​
Name | Type |
---|---|
options | ResolveOptions <any > |
Returns​
BaseSchema
<TCast
, TContext
, TOutput
>
strict​
â–¸ strict(isStrict?
): BaseSchema
<TCast
, TContext
, TOutput
>
Parameters​
Name | Type |
---|---|
isStrict? | boolean |
Returns​
BaseSchema
<TCast
, TContext
, TOutput
>
strip​
â–¸ strip(strip?
): BaseSchema
<TCast
, TContext
, TOutput
>
Parameters​
Name | Type |
---|---|
strip? | boolean |
Returns​
BaseSchema
<TCast
, TContext
, TOutput
>
test​
â–¸ test(options
): BaseSchema
<TCast
, TContext
, TOutput
>
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​
Name | Type |
---|---|
options | TestConfig <TCast , TContext > |
Returns​
BaseSchema
<TCast
, TContext
, TOutput
>
â–¸ test(test
): BaseSchema
<TCast
, TContext
, TOutput
>
Parameters​
Name | Type |
---|---|
test | TestFunction <TCast , TContext > |
Returns​
BaseSchema
<TCast
, TContext
, TOutput
>
â–¸ test(name
, test
): BaseSchema
<TCast
, TContext
, TOutput
>
Parameters​
Name | Type |
---|---|
name | string |
test | TestFunction <TCast , TContext > |
Returns​
BaseSchema
<TCast
, TContext
, TOutput
>
â–¸ test(name
, message
, test
): BaseSchema
<TCast
, TContext
, TOutput
>
Parameters​
Name | Type |
---|---|
name | string |
message | Message <{}> |
test | TestFunction <TCast , TContext > |
Returns​
BaseSchema
<TCast
, TContext
, TOutput
>
transform​
â–¸ transform(fn
): BaseSchema
<TCast
, TContext
, TOutput
>
Parameters​
Name | Type |
---|---|
fn | TransformFunction <BaseSchema <TCast , TContext , TOutput >> |
Returns​
BaseSchema
<TCast
, TContext
, TOutput
>
typeError​
â–¸ typeError(message
): BaseSchema
<TCast
, TContext
, TOutput
>
Parameters​
Name | Type |
---|---|
message | Message <{}> |
Returns​
BaseSchema
<TCast
, TContext
, TOutput
>
validate​
â–¸ validate(value
, options?
): Promise
<TOutput
>
Parameters​
Name | Type |
---|---|
value | any |
options? | ValidateOptions <TContext > |
Returns​
Promise
<TOutput
>
validateAt​
â–¸ validateAt(path
, value
, options?
): Promise
<TOutput
>
Parameters​
Name | Type |
---|---|
path | string |
value | any |
options? | ValidateOptions <TContext > |
Returns​
Promise
<TOutput
>
validateSync​
â–¸ validateSync(value
, options?
): TOutput
Parameters​
Name | Type |
---|---|
value | any |
options? | ValidateOptions <TContext > |
Returns​
TOutput
validateSyncAt​
â–¸ validateSyncAt(path
, value
, options?
): TOutput
Parameters​
Name | Type |
---|---|
path | string |
value | any |
options? | ValidateOptions <TContext > |
Returns​
TOutput
when​
â–¸ when(options
): BaseSchema
<TCast
, TContext
, TOutput
>
Parameters​
Name | Type |
---|---|
options | ConditionOptions <BaseSchema <TCast , TContext , TOutput >> |
Returns​
BaseSchema
<TCast
, TContext
, TOutput
>
â–¸ when(keys
, options
): BaseSchema
<TCast
, TContext
, TOutput
>
Parameters​
Name | Type |
---|---|
keys | string | string [] |
options | ConditionOptions <BaseSchema <TCast , TContext , TOutput >> |
Returns​
BaseSchema
<TCast
, TContext
, TOutput
>
withMutation​
â–¸ withMutation<T
>(fn
): T
Type parameters​
Name |
---|
T |
Parameters​
Name | Type |
---|---|
fn | (schema : BaseSchema <TCast , TContext , TOutput >) => T |
Returns​
T