@hypothesis/frontend-shared
Version:
Shared components, styles and utilities for Hypothesis projects
14 lines (13 loc) • 499 B
TypeScript
import type { RefObject } from 'preact';
export type InputLike = {
setCustomValidity(message: string): void;
};
/**
* Sync custom validation error messages to the browser's native validation
* state.
*
* @param ref - An `HTMLInputElement` or other element that supports the
* Constraint Validation API
* @param error - The current error or undefined if the field input is valid
*/
export declare function useValidationError(ref: RefObject<InputLike | undefined>, error?: string): void;