Ignore required field validation for booleans

This commit is contained in:
Jake McDermott
2020-07-01 11:59:05 -04:00
parent dbfb1780f1
commit ea4b435ea7

View File

@@ -12,7 +12,13 @@ function BaseInputController (strings) {
scope.state._touched = false; scope.state._touched = false;
scope.state._required = scope.state.required || false; scope.state._required = scope.state.required || false;
scope.state._isValid = scope.state._isValid || false;
if (scope.state.type === 'boolean') {
scope.state._isValid = scope.state._isValid || true;
} else {
scope.state._isValid = scope.state._isValid || false;
}
scope.state._disabled = scope.state._disabled || false; scope.state._disabled = scope.state._disabled || false;
scope.state._activeModel = scope.state._activeModel || '_value'; scope.state._activeModel = scope.state._activeModel || '_value';
@@ -59,6 +65,10 @@ function BaseInputController (strings) {
scope.state._touched = true; scope.state._touched = true;
} }
if (scope.state.type === 'boolean') {
return { isValid, message };
}
if (scope.state._required && (!scope.state._value || !scope.state._value[0]) && if (scope.state._required && (!scope.state._value || !scope.state._value[0]) &&
!scope.state._displayValue) { !scope.state._displayValue) {
isValid = false; isValid = false;