Skip to content

Commit 5ddca06

Browse files
Jaideep PannuJaideep Pannu
authored andcommitted
fix(react-form-renderer): fix numeric validator
1 parent 1fa4870 commit 5ddca06

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

packages/react-form-renderer/src/tests/validators/validators.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ describe('New validators', () => {
131131
it('should not pass the validation and return custom message', () => {
132132
expect(validatorMapper[validatorTypes.MIN_NUMBER_VALUE]({ value: 99, message: 'Foo' })(1)).toEqual('Foo');
133133
});
134+
135+
it('should not pass the validation (with value as 0)', () => {
136+
expect(validatorMapper[validatorTypes.MIN_NUMBER_VALUE]({ value: 2 })(0)).toEqual('Value must be greater than or equal to 2.');
137+
});
134138
});
135139

136140
describe('max value validator', () => {

packages/react-form-renderer/src/validators/validator-functions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const numericality = memoize(
9090
lessOrEqual = selectNum(lessOrEqual, lessThanOrEqualTo);
9191

9292
return prepare((value) => {
93-
if (!value) {
93+
if (value == null) {
9494
return;
9595
}
9696

0 commit comments

Comments
 (0)