Keep a value together with its validity and the last value that was valid.
This is custom React hooks, you need to follow the Basic Rules when you use it.
The email is valid when it matches a simple pattern.
const useValidatedState = <T>(
initialValue: T,
validate: (value: T) => boolean,
) => [
{ value: T; lastValidValue: T | undefined; valid: boolean },
(value: T) => void,
]