Skip to content
This repository was archived by the owner on Oct 20, 2021. It is now read-only.

Commit 471f0ba

Browse files
fix(rules): Validate NumberVal before
1 parent d54bf18 commit 471f0ba

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/rules/multiple.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { AbstractRule } from './abstract-rule';
2+
import { NumberVal } from './number-val';
23

34
export class Multiple extends AbstractRule {
45

@@ -13,6 +14,10 @@ export class Multiple extends AbstractRule {
1314
* Validate.
1415
*/
1516
public validate(input: any): boolean {
17+
if (!new NumberVal().validate(input)) {
18+
return false;
19+
}
20+
1621
if (this.multipleOf === 0) {
1722
return this.multipleOf === input;
1823
}

src/rules/negative.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { AbstractRule } from './abstract-rule';
2+
import { NumberVal } from './number-val';
23

34
export class Negative extends AbstractRule {
45

56
/**
67
* Validate.
78
*/
89
public validate(input: any): boolean {
10+
if (!new NumberVal().validate(input)) {
11+
return false;
12+
}
13+
914
return input < 0;
1015
}
1116
}

src/rules/positive.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { AbstractRule } from './abstract-rule';
2+
import { NumberVal } from './number-val';
23

34
export class Positive extends AbstractRule {
45

56
/**
67
* Validate.
78
*/
89
public validate(input: any): boolean {
10+
if (!new NumberVal().validate(input)) {
11+
return false;
12+
}
13+
914
return input > 0;
1015
}
1116
}

0 commit comments

Comments
 (0)