|
|
|
@ -241,19 +241,6 @@ function validator(fallback, fn) {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {number} fallback
|
|
|
|
|
* @returns {Validator}
|
|
|
|
|
*/
|
|
|
|
|
function number(fallback) {
|
|
|
|
|
return validator(fallback, (input, keypath) => {
|
|
|
|
|
if (typeof input !== 'number') {
|
|
|
|
|
throw_error(`${keypath} should be a number, if specified`);
|
|
|
|
|
}
|
|
|
|
|
return input;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {string | undefined} fallback
|
|
|
|
|
* @param {boolean} allow_empty
|
|
|
|
@ -273,20 +260,6 @@ function string(fallback, allow_empty = true) {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {string[]} fallback
|
|
|
|
|
* @returns {Validator}
|
|
|
|
|
*/
|
|
|
|
|
function string_array(fallback) {
|
|
|
|
|
return validator(fallback, (input, keypath) => {
|
|
|
|
|
if (input && !Array.isArray(input)) {
|
|
|
|
|
throw_error(`${keypath} should be a string array, if specified`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return input;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {boolean | undefined} fallback
|
|
|
|
|
* @returns {Validator}
|
|
|
|
|