Yup
Install
Usage
Using a custom locale dictionary
API
yup
yupyup.reach(schema: Schema, path: string, value?: object, context?: object): Schema
yup.reach(schema: Schema, path: string, value?: object, context?: object): Schemayup.addMethod(schemaType: Schema, name: string, method: ()=> Schema): void
yup.addMethod(schemaType: Schema, name: string, method: ()=> Schema): voidyup.ref(path: string, options: { contextPrefix: string }): Ref
yup.ref(path: string, options: { contextPrefix: string }): Refyup.lazy((value: any) => Schema): Lazy
yup.lazy((value: any) => Schema): LazyValidationError(errors: string | Array<string>, value: any, path: string)
ValidationError(errors: string | Array<string>, value: any, path: string)mixed
mixed.clone(): Schema
mixed.clone(): Schemamixed.label(label: string): Schema
mixed.label(label: string): Schemamixed.meta(metadata: object): Schema
mixed.meta(metadata: object): Schemamixed.describe(): SchemaDescription
mixed.describe(): SchemaDescriptionmixed.concat(schema: Schema): Schema
mixed.concat(schema: Schema): Schemamixed.validate(value: any, options?: object): Promise<any, ValidationError>
mixed.validate(value: any, options?: object): Promise<any, ValidationError>mixed.validateSync(value: any, options?: object): any
mixed.validateSync(value: any, options?: object): anymixed.validateAt(path: string, value: any, options?: object): Promise<any, ValidationError>
mixed.validateAt(path: string, value: any, options?: object): Promise<any, ValidationError>mixed.validateSyncAt(path: string, value: any, options?: object): any
mixed.validateSyncAt(path: string, value: any, options?: object): anymixed.isValid(value: any, options?: object): Promise<boolean>
mixed.isValid(value: any, options?: object): Promise<boolean>mixed.isValidSync(value: any, options?: object): boolean
mixed.isValidSync(value: any, options?: object): booleanmixed.cast(value: any, options = {}): any
mixed.cast(value: any, options = {}): anymixed.isType(value: any): boolean
mixed.isType(value: any): booleanmixed.strict(isStrict: boolean = false): Schema
mixed.strict(isStrict: boolean = false): Schemamixed.strip(stripField: boolean = true): Schema
mixed.strip(stripField: boolean = true): Schemamixed.withMutation(builder: (current: Schema) => void): void
mixed.withMutation(builder: (current: Schema) => void): voidmixed.default(value: any): Schema
mixed.default(value: any): Schemamixed.getDefault(options?: object): Any
mixed.getDefault(options?: object): Anymixed.nullable(isNullable: boolean = true): Schema
mixed.nullable(isNullable: boolean = true): Schemamixed.required(message?: string | function): Schema
mixed.required(message?: string | function): Schemamixed.notRequired(): Schema Alias: optional()
mixed.notRequired(): Schema Alias: optional()mixed.defined(): Schema
mixed.defined(): Schemamixed.typeError(message: string): Schema
mixed.typeError(message: string): Schemamixed.oneOf(arrayOfValues: Array<any>, message?: string | function): Schema Alias: equals
mixed.oneOf(arrayOfValues: Array<any>, message?: string | function): Schema Alias: equalsmixed.notOneOf(arrayOfValues: Array<any>, message?: string | function)
mixed.notOneOf(arrayOfValues: Array<any>, message?: string | function)mixed.when(keys: string | Array<string>, builder: object | (value, schema)=> Schema): Schema
mixed.when(keys: string | Array<string>, builder: object | (value, schema)=> Schema): Schemamixed.test(name: string, message: string | function, test: function): Schema
mixed.test(name: string, message: string | function, test: function): Schemamixed.test(options: object): Schema
mixed.test(options: object): Schemamixed.transform((currentValue: any, originalValue: any) => any): Schema
mixed.transform((currentValue: any, originalValue: any) => any): Schemastring
string.required(message?: string | function): Schema
string.required(message?: string | function): Schemastring.length(limit: number | Ref, message?: string | function): Schema
string.length(limit: number | Ref, message?: string | function): Schemastring.min(limit: number | Ref, message?: string | function): Schema
string.min(limit: number | Ref, message?: string | function): Schemastring.max(limit: number | Ref, message?: string | function): Schema
string.max(limit: number | Ref, message?: string | function): Schemastring.matches(regex: Regex, message?: string | function): Schema
string.matches(regex: Regex, message?: string | function): Schemastring.matches(regex: Regex, options: { message: string, excludeEmptyString: bool }): Schema
string.matches(regex: Regex, options: { message: string, excludeEmptyString: bool }): Schemastring.email(message?: string | function): Schema
string.email(message?: string | function): Schemastring.url(message?: string | function): Schema
string.url(message?: string | function): Schemastring.uuid(message?: string | function): Schema
string.uuid(message?: string | function): Schemastring.ensure(): Schema
string.ensure(): Schemastring.trim(message?: string | function): Schema
string.trim(message?: string | function): Schemastring.lowercase(message?: string | function): Schema
string.lowercase(message?: string | function): Schemastring.uppercase(message?: string | function): Schema
string.uppercase(message?: string | function): Schemanumber
number.min(limit: number | Ref, message?: string | function): Schema
number.min(limit: number | Ref, message?: string | function): Schemanumber.max(limit: number | Ref, message?: string | function): Schema
number.max(limit: number | Ref, message?: string | function): Schemanumber.lessThan(max: number | Ref, message?: string | function): Schema
number.lessThan(max: number | Ref, message?: string | function): Schemanumber.moreThan(min: number | Ref, message?: string | function): Schema
number.moreThan(min: number | Ref, message?: string | function): Schemanumber.positive(message?: string | function): Schema
number.positive(message?: string | function): Schemanumber.negative(message?: string | function): Schema
number.negative(message?: string | function): Schemanumber.integer(message?: string | function): Schema
number.integer(message?: string | function): Schemanumber.truncate(): Schema
number.truncate(): Schemanumber.round(type: 'floor' | 'ceil' | 'trunc' | 'round' = 'round'): Schema
number.round(type: 'floor' | 'ceil' | 'trunc' | 'round' = 'round'): Schemaboolean
date
date.min(limit: Date | string | Ref, message?: string | function): Schema
date.min(limit: Date | string | Ref, message?: string | function): Schemadate.max(limit: Date | string | Ref, message?: string | function): Schema
date.max(limit: Date | string | Ref, message?: string | function): Schemaarray
array.of(type: Schema): Schema
array.of(type: Schema): Schemaarray.length(length: number | Ref, message?: string | function): Schema
array.length(length: number | Ref, message?: string | function): Schemaarray.min(limit: number | Ref, message?: string | function): Schema
array.min(limit: number | Ref, message?: string | function): Schemaarray.max(limit: number | Ref, message?: string | function): Schema
array.max(limit: number | Ref, message?: string | function): Schemaarray.ensure(): Schema
array.ensure(): Schemaarray.compact(rejector: (value) => boolean): Schema
array.compact(rejector: (value) => boolean): Schemaobject
Object schema defaults
object.shape(fields: object, noSortEdges?: Array<[string, string]>): Schema
object.shape(fields: object, noSortEdges?: Array<[string, string]>): Schemaobject.pick(keys: string[]): Schema
object.pick(keys: string[]): Schemaobject.omit(keys: string[]): Schema
object.omit(keys: string[]): Schemaobject.from(fromKey: string, toKey: string, alias: boolean = false): Schema
object.from(fromKey: string, toKey: string, alias: boolean = false): Schemaobject.noUnknown(onlyKnownKeys: boolean = true, message?: string | function): Schema
object.noUnknown(onlyKnownKeys: boolean = true, message?: string | function): Schemaobject.camelCase(): Schema
object.camelCase(): Schemaobject.constantCase(): Schema
object.constantCase(): SchemaExtending Schema Types
TypeScript Support
TypeScript setting
Last updated