File tree 2 files changed +5
-11
lines changed
packages/n4s/src/plugins/compounds
2 files changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -7,13 +7,7 @@ import 'compounds';
7
7
describe ( 'enforce.oneOf' , ( ) => {
8
8
it ( 'Should fail when multiple enforcements are met' , ( ) => {
9
9
expect (
10
- User . run ( {
11
- id : 11 ,
12
- name : {
13
- first : 'John' ,
14
- last : 'Doe' ,
15
- } ,
16
- } )
10
+ enforce . oneOf ( enforce . isNumber ( ) , enforce . greaterThan ( 2 ) ) . run ( 3 )
17
11
) . toEqual ( ruleReturn . failing ( ) ) ;
18
12
} ) ;
19
13
Original file line number Diff line number Diff line change @@ -9,15 +9,15 @@ const REQUIRED_COUNT = 1;
9
9
export function oneOf ( value : unknown , ...rules : Lazy [ ] ) : RuleDetailedResult {
10
10
const passing : RuleDetailedResult [ ] = [ ] ;
11
11
rules . some ( rule => {
12
- if ( longerThan ( passing , REQUIRED_COUNT ) ) {
13
- return false ;
14
- }
15
-
16
12
const res = runLazyRule ( rule , value ) ;
17
13
18
14
if ( res . pass ) {
19
15
passing . push ( res ) ;
20
16
}
17
+
18
+ if ( longerThan ( passing , REQUIRED_COUNT ) ) {
19
+ return false ;
20
+ }
21
21
} ) ;
22
22
23
23
return ruleReturn ( lengthEquals ( passing , REQUIRED_COUNT ) ) ;
You can’t perform that action at this time.
0 commit comments