Prevent validator being called on non-strings
This commit is contained in:
@ -61,15 +61,15 @@ const checkboxClass = dedent`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
function formatValue(value, validator, type = 'string') {
|
function formatValue(value, validator, type = 'string') {
|
||||||
const formated = getDefaults(type);
|
const formatted = getDefaults(type);
|
||||||
if (validator && type === 'string') {
|
if (validator && type === 'string' && typeof value === 'string') {
|
||||||
formated.valid = validator(value);
|
formatted.valid = validator(value);
|
||||||
}
|
}
|
||||||
if (value) {
|
if (value) {
|
||||||
formated.value = value;
|
formatted.value = value;
|
||||||
formated.bsStyle = formated.valid ? 'success' : 'error';
|
formatted.bsStyle = formatted.valid ? 'success' : 'error';
|
||||||
}
|
}
|
||||||
return formated;
|
return formatted;
|
||||||
}
|
}
|
||||||
|
|
||||||
const normalizeOptions = {
|
const normalizeOptions = {
|
||||||
|
Reference in New Issue
Block a user