-
Notifications
You must be signed in to change notification settings - Fork 18
Conversation
@@ -21,13 +23,13 @@ module.exports = function (opts) { | |||
} | |||
|
|||
if (opts) { | |||
if (opts.min && opts.max && (value < opts.min || value > opts.max)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small optimisation but should we do
if (opts) {
var hasMinValue = hasValue(opts.min);
var hasMaxValue = hasValue(opts.max);
if ( hasMinValue && hasMaxValue && (value < opts.min || value > opts.max)) {
return 'should be a number between ' + opts.min + ' and ' + opts.max;
}
if (hasMinValue && value < opts.min) {
return 'should be a number >= ' + opts.min;
}
if (hasMaxValue && value > opts.max) {
return 'should be a number <= ' + opts.max;
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nguyenchr Nice optimisation.
Nice catch! 👍 I think we might have similar bugs in On top of this, maybe we could add some checks on |
@nguyenchr Your suggestion is applied. |
nice one 👍 is it worth making the same change to |
@rprieto @nguyenchr Good idea. I will extend this PR to fix other matchers as well. |
@rprieto @nguyenchr Actually I don't think using this new method in |
Proper validation of min and max optimization min=0 or max=0 bug fix for Integer matcher. Refacotring integer and number matchers. Refactoring number matcher
Good point! |
👍 |
Better formatting for title of releases
Per chat with @nguyenchr |
Bug fix in validation of data via `integer` and `number` matchers when `{min: 0}` or `{max: 0}`
This PR addresses this bug #20