Skip to content

Commit

Permalink
fix: set valid state to valid on validation disable
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver committed Feb 7, 2024
1 parent c22b51d commit 8803445
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/platform/src/lib/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ export function createValidateState(): WritableSignal<ValidateState> {
});
}

export function executeValidator(
state: WritableSignal<ValidateState>,
value: unknown,
validator: Validator) {
export function executeValidator(state: WritableSignal<ValidateState>, value: unknown, validator: Validator) {
if (typeof validator === 'function') {
validator(value, (newState, newErrors?) => {
state.set({state: newState, errors: (newErrors as ValidationErrors) ?? null});
Expand All @@ -61,6 +58,8 @@ export function createValidateState(): WritableSignal<ValidateState> {
}
state.set({state: newState, errors: newErrors ?? null});
});
} else {
state.set({state: 'VALID', errors: null});
}
return;
}
Expand Down

0 comments on commit 8803445

Please sign in to comment.