File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,13 @@ export interface BaseSchema<T> {
77 enum : ( values : Array < any > ) => T
88 const : ( value : any ) => T
99 default : ( value : any ) => T
10- required : ( ) => T
10+ required : ( fields ?: string [ ] ) => T
11+ ifThen : ( ifClause : JSONSchema , thenClause : JSONSchema ) => T
12+ ifThenElse : (
13+ ifClause : JSONSchema ,
14+ thenClause : JSONSchema ,
15+ elseClause : JSONSchema
16+ ) => T
1117 not : ( schema : JSONSchema ) => T
1218 anyOf : ( schema : Array < JSONSchema > ) => T
1319 allOf : ( schema : Array < JSONSchema > ) => T
@@ -58,7 +64,7 @@ export interface StringSchema extends BaseSchema<StringSchema> {
5864 minLength : ( min : number ) => StringSchema
5965 maxLength : ( min : number ) => StringSchema
6066 format : ( format : FORMATS ) => StringSchema
61- pattern : ( pattern : string ) => StringSchema
67+ pattern : ( pattern : string | RegExp ) => StringSchema
6268 contentEncoding : ( encoding : string ) => StringSchema
6369 contentMediaType : ( mediaType : string ) => StringSchema
6470}
Original file line number Diff line number Diff line change @@ -47,7 +47,8 @@ const schema = S.object()
4747 )
4848 . required ( )
4949 . prop ( 'age' , S . mixed < NumberSchema & StringSchema > ( [ 'string' , 'integer' ] ) )
50+ . ifThen ( S . object ( ) . prop ( 'age' , S . string ( ) ) , S . required ( [ 'age' ] ) )
5051
5152 . valueOf ( )
5253
53- console . log ( { schema } )
54+ console . log ( JSON . stringify ( schema ) )
You can’t perform that action at this time.
0 commit comments