MCPcopy
hub / github.com/tdewolff/minify / number

Function number

_benchmarks/sample_antd.js:75259–75281  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

75257 */
75258
75259function 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.

Callers

nothing calls this directly

Calls 2

isEmptyValueFunction · 0.70
callbackFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…