File tree Expand file tree Collapse file tree 4 files changed +12
-3
lines changed Expand file tree Collapse file tree 4 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 7272 "rimraf" : " ^3.0.2" ,
7373 "standard-version" : " ^9.3.1" ,
7474 "ts-jest" : " ^27.1.1" ,
75+ "ts-node" : " ^10.9.1" ,
7576 "typescript" : " ^4.5.3" ,
7677 "vue" : " ^2.6.14"
7778 },
Original file line number Diff line number Diff line change @@ -14,8 +14,12 @@ describe('Validator', () => {
1414 validator . add ( 'name' , 'The name field is required.' )
1515 expect ( validator . any ( ) ) . toBeTruthy ( )
1616 } )
17+ test ( 'Add an error with forceUpdate' , ( ) => {
18+ validator . add ( 'name' , 'The name field is required.' , true )
19+ expect ( validator . any ( ) ) . toBeTruthy ( )
20+ } )
1721 test ( 'add error with missed attribute' , ( ) => {
18- validator . add ( 'name-3diidi ' , 'The name field is required.' )
22+ validator . add ( 'name-3 ' , 'The name field is required.' )
1923 expect ( validator . any ( ) ) . toBeTruthy ( )
2024 } )
2125 test ( 'Add an error message as string' , ( ) => {
Original file line number Diff line number Diff line change @@ -12,11 +12,15 @@ class Validator {
1212 this . errors = errors
1313 }
1414
15- add ( attribute : string , message : string ) {
15+ add ( attribute : string , message : string , forceUpdate ?: boolean ) {
1616 if ( this . missed ( attribute ) ) {
1717 this . errors [ attribute ] = [ ]
1818 }
1919 if ( ! this . errors [ attribute ] . includes ( message ) ) {
20+ this . errors [ attribute ] . unshift ( message )
21+ }
22+ if ( forceUpdate ) {
23+ this . errors [ attribute ] = [ ]
2024 this . errors [ attribute ] . push ( message )
2125 }
2226 }
Original file line number Diff line number Diff line change @@ -11309,7 +11309,7 @@ ts-jest@^27.1.1:
1130911309 semver "7.x"
1131011310 yargs-parser "20.x"
1131111311
11312- ts-node@^10.8.1:
11312+ ts-node@^10.8.1, ts-node@^10.9.1 :
1131311313 version "10.9.1"
1131411314 resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b"
1131511315 integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==
You can’t perform that action at this time.
0 commit comments