impr(input-validation): add trigger validation function

!nuf
This commit is contained in:
Miodec 2025-09-24 14:35:46 +02:00
parent 505049338f
commit 9e5e4831a8

View file

@ -146,6 +146,7 @@ export type ValidationOptions<T> = (T extends string
export type ValidatedHtmlInputElement = HTMLInputElement & {
isValid: () => boolean | undefined;
setValue: (val: string | null) => void;
triggerValidation: () => void;
};
/**
* adds an 'InputIndicator` to the given `inputElement` and updates its status depending on the given validation
@ -207,6 +208,9 @@ export function validateWithIndicator<T>(
inputElement.dispatchEvent(new Event("input"));
}
};
result.triggerValidation = () => {
inputElement.dispatchEvent(new Event("input"));
};
return result;
}