* Validates a number. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The vali
(rule, value, callback, source, options)
| 75257 | */ |
| 75258 | |
| 75259 | function number(rule, value, callback, source, options) { |
| 75260 | var errors = []; |
| 75261 | var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); |
| 75262 | |
| 75263 | if (validate) { |
| 75264 | if (value === '') { |
| 75265 | value = undefined; |
| 75266 | } |
| 75267 | |
| 75268 | if (isEmptyValue(value) && !rule.required) { |
| 75269 | return callback(); |
| 75270 | } |
| 75271 | |
| 75272 | rules.required(rule, value, source, errors, options); |
| 75273 | |
| 75274 | if (value !== undefined) { |
| 75275 | rules.type(rule, value, source, errors, options); |
| 75276 | rules.range(rule, value, source, errors, options); |
| 75277 | } |
| 75278 | } |
| 75279 | |
| 75280 | callback(errors); |
| 75281 | } |
| 75282 | |
| 75283 | /** |
| 75284 | * Validates a boolean. |
nothing calls this directly
no test coverage detected
searching dependent graphs…