Skip to main content

Class: BooleanSchema<TType, TContext, TOut>

yup.BooleanSchema

Type parameters​

NameType
TTypeextends Maybe<boolean> = boolean | undefined
TContextextends AnyObject = AnyObject
TOutextends TType = TType

Hierarchy​

  • BaseSchema<TType, TContext, TOut>

    ↳ BooleanSchema

Constructors​

constructor​

• new BooleanSchema<TType, TContext, TOut>()

Type parameters​

NameType
TTypeextends Maybe<boolean> = undefined | boolean
TContextextends AnyObject = AnyObject
TOutextends Maybe<boolean> = TType

Overrides​

BaseSchema.constructor

Properties​

__inputType​

• Readonly __inputType: TType

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


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​

_type​

• get _type(): string

Returns​

string

Inherited from​

BaseSchema._type

Methods​

_cast​

â–¸ Protected _cast(rawValue, _options): any

Parameters​

NameType
rawValueany
_optionsCastOptions<TContext>

Returns​

any

Inherited from​

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<TType>

Parameters​

NameType
vany

Returns​

v is NonNullable<TType>

Overrides​

BaseSchema._typeCheck


_validate​

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

Parameters​

NameType
_valueany
optionsundefined | InternalOptions<TContext>
cbCallback<any>

Returns​

void

Inherited from​

BaseSchema._validate


cast​

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

Parameters​

NameType
valueany
options?CastOptions<TContext>

Returns​

TType

Inherited from​

BaseSchema.cast


clone​

â–¸ clone(spec?): BooleanSchema<TType, TContext, TOut>

Parameters​

NameType
spec?Partial<SchemaSpec<any>>

Returns​

BooleanSchema<TType, TContext, TOut>

Inherited from​

BaseSchema.clone


concat​

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

Type parameters​

NameType
TOtherextends BooleanSchema<any, any, any, TOther>

Parameters​

NameType
schemaTOther

Returns​

TOther

Inherited from​

BaseSchema.concat


default​

â–¸ default<TNextDefault>(def): TNextDefault extends undefined ? BooleanSchema<undefined | TType, TContext, undefined | TType> : BooleanSchema<Defined<TType>, TContext, Defined<TType>>

Type parameters​

NameType
TNextDefaultextends Maybe<boolean>

Parameters​

NameType
defTNextDefault | () => TNextDefault

Returns​

TNextDefault extends undefined ? BooleanSchema<undefined | TType, TContext, undefined | TType> : BooleanSchema<Defined<TType>, TContext, Defined<TType>>

Inherited from​

BaseSchema.default


defined​

â–¸ defined(msg?): DefinedBooleanSchema<TType, TContext>

Parameters​

NameType
msg?Message<{}>

Returns​

DefinedBooleanSchema<TType, TContext>

Inherited from​

BaseSchema.defined


describe​

â–¸ describe(): SchemaDescription

Returns​

SchemaDescription

Inherited from​

BaseSchema.describe


getDefault​

â–¸ getDefault(options?): TType

Parameters​

NameType
options?ResolveOptions<any>

Returns​

TType

Inherited from​

BaseSchema.getDefault


isFalse​

â–¸ isFalse(message?): BooleanSchema<false | TType, TContext, false | Extract<TOut, undefined | null>>

Parameters​

NameType
message?string | Record<string | number | symbol, unknown> | (params: MessageParams) => unknown

Returns​

BooleanSchema<false | TType, TContext, false | Extract<TOut, undefined | null>>


isTrue​

â–¸ isTrue(message?): BooleanSchema<true | TType, TContext, true | Extract<TOut, undefined | null>>

Parameters​

NameType
message?string | Record<string | number | symbol, unknown> | (params: MessageParams) => unknown

Returns​

BooleanSchema<true | TType, TContext, true | Extract<TOut, undefined | null>>


isType​

â–¸ isType(v): boolean

Parameters​

NameType
vany

Returns​

boolean

Inherited from​

BaseSchema.isType


isValid​

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

Parameters​

NameType
valueany
options?ValidateOptions<TContext>

Returns​

Promise<boolean>

Inherited from​

BaseSchema.isValid


isValidSync​

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

Parameters​

NameType
valueany
options?ValidateOptions<TContext>

Returns​

value is TOut

Inherited from​

BaseSchema.isValidSync


label​

â–¸ label(label): BooleanSchema<TType, TContext, TOut>

Parameters​

NameType
labelstring

Returns​

BooleanSchema<TType, TContext, TOut>

Inherited from​

BaseSchema.label


meta​

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

Returns​

undefined | Record<string, unknown>

Inherited from​

BaseSchema.meta

â–¸ meta(obj): BooleanSchema<TType, TContext, TOut>

Parameters​

NameType
objRecord<string, unknown>

Returns​

BooleanSchema<TType, TContext, TOut>

Inherited from​

BaseSchema.meta


notOneOf​

â–¸ notOneOf<U>(enums, message?): BooleanSchema<TType, TContext, TOut>

Type parameters​

NameType
Uextends Maybe<boolean>

Parameters​

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

Returns​

BooleanSchema<TType, TContext, TOut>

Inherited from​

BaseSchema.notOneOf


notRequired​

â–¸ notRequired(): BooleanSchema<TType, TContext, TType>

Returns​

BooleanSchema<TType, TContext, TType>

Inherited from​

BaseSchema.notRequired


nullable​

â–¸ nullable(isNullable?): BooleanSchema<null | TType, AnyObject, null | TType>

Parameters​

NameType
isNullable?true

Returns​

BooleanSchema<null | TType, AnyObject, null | TType>

Inherited from​

BaseSchema.nullable

â–¸ nullable(isNullable): BooleanSchema<Exclude<TType, null>, AnyObject, Exclude<TType, null>>

Parameters​

NameType
isNullablefalse

Returns​

BooleanSchema<Exclude<TType, null>, AnyObject, Exclude<TType, null>>

Inherited from​

BaseSchema.nullable


oneOf​

â–¸ oneOf<U>(enums, message?): BooleanSchema<TType, TContext, TOut>

Type parameters​

NameType
Uextends Maybe<boolean>

Parameters​

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

Returns​

BooleanSchema<TType, TContext, TOut>

Inherited from​

BaseSchema.oneOf


optional​

â–¸ optional(): BooleanSchema<TType, TContext, TType>

Returns​

BooleanSchema<TType, TContext, TType>

Inherited from​

BaseSchema.optional


required​

â–¸ required(msg?): RequiredBooleanSchema<TType, TContext>

Parameters​

NameType
msg?Message<{}>

Returns​

RequiredBooleanSchema<TType, TContext>

Inherited from​

BaseSchema.required


resolve​

â–¸ resolve(options): BooleanSchema<TType, TContext, TOut>

Parameters​

NameType
optionsResolveOptions<any>

Returns​

BooleanSchema<TType, TContext, TOut>

Inherited from​

BaseSchema.resolve


strict​

â–¸ strict(isStrict?): BooleanSchema<TType, TContext, TOut>

Parameters​

NameType
isStrict?boolean

Returns​

BooleanSchema<TType, TContext, TOut>

Inherited from​

BaseSchema.strict


strip​

â–¸ strip(strip?): BooleanSchema<TType, TContext, TOut>

Parameters​

NameType
strip?boolean

Returns​

BooleanSchema<TType, TContext, TOut>

Inherited from​

BaseSchema.strip


test​

â–¸ test(options): BooleanSchema<TType, TContext, 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<TType, TContext>

Returns​

BooleanSchema<TType, TContext, TOut>

Inherited from​

BaseSchema.test

â–¸ test(test): BooleanSchema<TType, TContext, TOut>

Parameters​

NameType
testTestFunction<TType, TContext>

Returns​

BooleanSchema<TType, TContext, TOut>

Inherited from​

BaseSchema.test

â–¸ test(name, test): BooleanSchema<TType, TContext, TOut>

Parameters​

NameType
namestring
testTestFunction<TType, TContext>

Returns​

BooleanSchema<TType, TContext, TOut>

Inherited from​

BaseSchema.test

â–¸ test(name, message, test): BooleanSchema<TType, TContext, TOut>

Parameters​

NameType
namestring
messageMessage<{}>
testTestFunction<TType, TContext>

Returns​

BooleanSchema<TType, TContext, TOut>

Inherited from​

BaseSchema.test


transform​

â–¸ transform(fn): BooleanSchema<TType, TContext, TOut>

Parameters​

NameType
fnTransformFunction<BooleanSchema<TType, TContext, TOut>>

Returns​

BooleanSchema<TType, TContext, TOut>

Inherited from​

BaseSchema.transform


typeError​

â–¸ typeError(message): BooleanSchema<TType, TContext, TOut>

Parameters​

NameType
messageMessage<{}>

Returns​

BooleanSchema<TType, TContext, TOut>

Inherited from​

BaseSchema.typeError


validate​

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

Parameters​

NameType
valueany
options?ValidateOptions<TContext>

Returns​

Promise<TOut>

Inherited from​

BaseSchema.validate


validateAt​

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

Parameters​

NameType
pathstring
valueany
options?ValidateOptions<TContext>

Returns​

Promise<TOut>

Inherited from​

BaseSchema.validateAt


validateSync​

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

Parameters​

NameType
valueany
options?ValidateOptions<TContext>

Returns​

TOut

Inherited from​

BaseSchema.validateSync


validateSyncAt​

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

Parameters​

NameType
pathstring
valueany
options?ValidateOptions<TContext>

Returns​

TOut

Inherited from​

BaseSchema.validateSyncAt


when​

â–¸ when(options): BooleanSchema<TType, TContext, TOut>

Parameters​

NameType
optionsConditionOptions<BooleanSchema<TType, TContext, TOut>>

Returns​

BooleanSchema<TType, TContext, TOut>

Inherited from​

BaseSchema.when

â–¸ when(keys, options): BooleanSchema<TType, TContext, TOut>

Parameters​

NameType
keysstring | string[]
optionsConditionOptions<BooleanSchema<TType, TContext, TOut>>

Returns​

BooleanSchema<TType, TContext, TOut>

Inherited from​

BaseSchema.when


withMutation​

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

Type parameters​

Name
T

Parameters​

NameType
fn(schema: BooleanSchema<TType, TContext, TOut>) => T

Returns​

T

Inherited from​

BaseSchema.withMutation