File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ export default class StringSchema<
9797
9898 notRequired ( ) {
9999 return super . notRequired ( ) . withMutation ( ( schema : this) => {
100- schema . tests . filter ( ( t ) => t . OPTIONS ! . name !== 'required' ) ;
100+ schema . tests = schema . tests . filter ( ( t ) => t . OPTIONS ! . name !== 'required' ) ;
101101 return schema ;
102102 } ) ;
103103 }
Original file line number Diff line number Diff line change @@ -94,6 +94,15 @@ describe('String types', () => {
9494 ] ) ;
9595 } ) ;
9696
97+ it ( 'should handle NOTREQUIRED correctly' , function ( ) {
98+ let v = string ( ) . required ( ) . notRequired ( ) ;
99+
100+ return Promise . all ( [
101+ expect ( v . isValid ( undefined ) ) . resolves . toBe ( true ) ,
102+ expect ( v . isValid ( '' ) ) . resolves . toBe ( true ) ,
103+ ] ) ;
104+ } ) ;
105+
97106 it ( 'should check MATCHES correctly' , function ( ) {
98107 let v = string ( ) . matches ( / ( h i | b y e ) / , 'A message' ) ;
99108
You can’t perform that action at this time.
0 commit comments