mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-07 16:05:12 +08:00
impr(input-validation): add trigger validation function
!nuf
This commit is contained in:
parent
505049338f
commit
9e5e4831a8
1 changed files with 4 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue