Skip to content

Commit

Permalink
feat(validator): 优化 when 的类型
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Dec 30, 2021
1 parent 6db08f0 commit 5206139
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/validator/yupTypes/mixed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,19 @@ export interface MixedSchema<T = any> {

notOneOf(arrayOfValues: T[], message?: MixedLocale['notOneOf']): this

/** @仅保留了类型友好的用法 */
when(builder: (value: T, schema: this) => this): this

when<V>(
key: string,
builder: {
is: boolean | ((value: V) => boolean)
then: GetSchema<T>
otherwise: GetSchema<T>
},
): this

when<V>(key: string, builder: (value: V, schema: this) => this): this

test(
test: SchemaTestOptions<this, T>['test'] | RegExp,
message?: SchemaTestOptions<this, T>['message'],
Expand Down

0 comments on commit 5206139

Please sign in to comment.