Skip to content

Commit e36a866

Browse files
authored
Merge pull request #1384 from jspannu919/num_validator_message_fix
Fix data type validation message for numeric validator in case of custom message
2 parents 667d373 + 2ce0685 commit e36a866

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
@@ -132,6 +132,10 @@ describe('New validators', () => {
132132
expect(validatorMapper[validatorTypes.MIN_NUMBER_VALUE]({ value: 99, message: 'Foo' })(1)).toEqual('Foo');
133133
});
134134

135+
it('should not pass the validation and return type error message', () => {
136+
expect(validatorMapper[validatorTypes.MIN_NUMBER_VALUE]({ value: 99, message: 'Foo' })('oo')).toEqual('Value is not a number');
137+
});
138+
135139
it('should not pass the validation (with value as 0)', () => {
136140
expect(validatorMapper[validatorTypes.MIN_NUMBER_VALUE]({ value: 2 })(0)).toEqual('Value must be greater than or equal to 2.');
137141
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export const numericality = memoize(
9595
}
9696

9797
if (!isNumber(value)) {
98-
return prepareMsg(message, 'notANumber').defaultMessage;
98+
return prepareMsg(null, 'notANumber').defaultMessage;
9999
}
100100

101101
if (equal !== null && +value !== equal) {

0 commit comments

Comments
 (0)