|
|
|
@ -92,21 +92,19 @@ |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
const newValue = value == null ? defaultValue : value |
|
|
|
const newError = validate ? validate(newValue) : null |
|
|
|
|
|
|
|
// Update field state |
|
|
|
const error = validate ? validate(value) : null |
|
|
|
fieldState.update(state => { |
|
|
|
state.value = newValue |
|
|
|
state.error = newError |
|
|
|
state.value = value |
|
|
|
state.error = error |
|
|
|
return state |
|
|
|
}) |
|
|
|
|
|
|
|
// Update form state |
|
|
|
formState.update(state => { |
|
|
|
state.values = { ...state.values, [field]: newValue } |
|
|
|
if (newError) { |
|
|
|
state.errors = { ...state.errors, [field]: newError } |
|
|
|
state.values = { ...state.values, [field]: value } |
|
|
|
if (error) { |
|
|
|
state.errors = { ...state.errors, [field]: error } |
|
|
|
} else { |
|
|
|
delete state.errors[field] |
|
|
|
} |
|
|
|
@ -114,7 +112,7 @@ |
|
|
|
return state |
|
|
|
}) |
|
|
|
|
|
|
|
return !newError |
|
|
|
return !error |
|
|
|
} |
|
|
|
|
|
|
|
const clearValue = () => { |
|
|
|
|