Neo Zero

react-forms

Pool

Modern, performant React form library - 78% smaller than Formik, perfect TypeScript inference

$ lpm install @lpm.dev/neo.react-forms
272 exportsTypeScript

dist

Functions

useForm
function useForm<Values extends Record<string, unknown>>(options: UseFormOptions<Values>): UseFormReturn<Values>

Main useForm hook

ParameterTypeDescription
options
UseFormOptions<Values>

dist/adapters

Functions

zodAdapter
function zodAdapter<T extends ZodObject>(schema: T): ValidationSchema<ZodInfer<T>>

Convert Zod object schema to ValidationSchema

ParameterTypeDescription
schema
T- Zod object schema
zodForm
function zodForm<T extends ZodObject>(schema: T, initialValues: ZodInfer<T>): {
    initialValues: ZodInfer<T>;
    validate: ValidationSchema<ZodInfer<T>>;
}

Helper to create form with Zod schema and automatic type inference

ParameterTypeDescription
schema
T- Zod schema
initialValues
ZodInfer<T>- Initial form values (must match schema type)

dist/adapters

Functions

zodAdapter
function zodAdapter<T extends ZodObject>(schema: T): ValidationSchema<ZodInfer<T>>

Convert Zod object schema to ValidationSchema

ParameterTypeDescription
schema
T- Zod object schema
zodForm
function zodForm<T extends ZodObject>(schema: T, initialValues: ZodInfer<T>): {
    initialValues: ZodInfer<T>;
    validate: ValidationSchema<ZodInfer<T>>;
}

Helper to create form with Zod schema and automatic type inference

ParameterTypeDescription
schema
T- Zod schema
initialValues
ZodInfer<T>- Initial form values (must match schema type)

dist/index-B4V7GjKf

Functions

required
function required(message?: string): Validator<string>

Required field validator

ParameterTypeDescription
messageoptional
string- Custom error message
email
function email(message?: string): Validator<string>

Email validator

ParameterTypeDescription
messageoptional
string- Custom error message
url
function url(message?: string): Validator<string>

URL validator

ParameterTypeDescription
messageoptional
string- Custom error message
minLength
function minLength(min: number, message?: string): Validator<string>

Minimum length validator

ParameterTypeDescription
min
number- Minimum length
messageoptional
string- Custom error message
maxLength
function maxLength(max: number, message?: string): Validator<string>

Maximum length validator

ParameterTypeDescription
max
number- Maximum length
messageoptional
string- Custom error message
pattern
function pattern(pattern: RegExp, message?: string): Validator<string>

Pattern validator (regex)

ParameterTypeDescription
pattern
RegExp- Regular expression
messageoptional
string- Custom error message
alphanumeric
function alphanumeric(message?: string): Validator<string>

Alphanumeric validator (letters and numbers only)

ParameterTypeDescription
messageoptional
string- Custom error message
alpha
function alpha(message?: string): Validator<string>

Alpha validator (letters only)

ParameterTypeDescription
messageoptional
string- Custom error message
lowercase
function lowercase(message?: string): Validator<string>

Lowercase validator

ParameterTypeDescription
messageoptional
string- Custom error message
uppercase
function uppercase(message?: string): Validator<string>

Uppercase validator

ParameterTypeDescription
messageoptional
string- Custom error message
trimmed
function trimmed(message?: string): Validator<string>

Trim validator (no leading/trailing whitespace)

ParameterTypeDescription
messageoptional
string- Custom error message
contains
function contains(substring: string, message?: string): Validator<string>

Contains validator (must include substring)

ParameterTypeDescription
substring
string- Substring to check for
messageoptional
string- Custom error message
startsWith
function startsWith(prefix: string, message?: string): Validator<string>

Starts with validator

ParameterTypeDescription
prefix
string- Prefix to check for
messageoptional
string- Custom error message
endsWith
function endsWith(suffix: string, message?: string): Validator<string>

Ends with validator

ParameterTypeDescription
suffix
string- Suffix to check for
messageoptional
string- Custom error message
min
function min(minValue: number, message?: string): Validator<number>

Minimum value validator

ParameterTypeDescription
minValue
number- Minimum allowed value
messageoptional
string- Custom error message
max
function max(maxValue: number, message?: string): Validator<number>

Maximum value validator

ParameterTypeDescription
maxValue
number- Maximum allowed value
messageoptional
string- Custom error message
between
function between(minValue: number, maxValue: number, message?: string): Validator<number>

Range validator (between min and max)

ParameterTypeDescription
minValue
number- Minimum value
maxValue
number- Maximum value
messageoptional
string- Custom error message
integer
function integer(message?: string): Validator<number>

Integer validator

ParameterTypeDescription
messageoptional
string- Custom error message
positive
function positive(message?: string): Validator<number>

Positive number validator (> 0)

ParameterTypeDescription
messageoptional
string- Custom error message
negative
function negative(message?: string): Validator<number>

Negative number validator (< 0)

ParameterTypeDescription
messageoptional
string- Custom error message
nonNegative
function nonNegative(message?: string): Validator<number>

Non-negative validator (>= 0)

ParameterTypeDescription
messageoptional
string- Custom error message
nonPositive
function nonPositive(message?: string): Validator<number>

Non-positive validator (<= 0)

ParameterTypeDescription
messageoptional
string- Custom error message
safeInteger
function safeInteger(message?: string): Validator<number>

Safe integer validator (within Number.MIN_SAFE_INTEGER and Number.MAX_SAFE_INTEGER)

ParameterTypeDescription
messageoptional
string- Custom error message
finite
function finite(message?: string): Validator<number>

Finite number validator (not Infinity or NaN)

ParameterTypeDescription
messageoptional
string- Custom error message
multipleOf
function multipleOf(divisor: number, message?: string): Validator<number>

Multiple of validator (divisible by)

ParameterTypeDescription
divisor
number- The number to divide by
messageoptional
string- Custom error message
even
function even(message?: string): Validator<number>

Even number validator

ParameterTypeDescription
messageoptional
string- Custom error message
odd
function odd(message?: string): Validator<number>

Odd number validator

ParameterTypeDescription
messageoptional
string- Custom error message
compose
function compose<T, Values = unknown>(validators: Validator<T, Values>[]): Validator<T, Values>

Compose multiple validators (runs all, returns first error)

ParameterTypeDescription
validators
Validator<T, Values>[]- Array of validators to compose
optional
function optional<T, Values = unknown>(validator: Validator<T, Values>): Validator<T | null | undefined, Values>

Optional validator (only validates if value exists)

ParameterTypeDescription
validator
Validator<T, Values>- Validator to make optional
when
function when<T, Values = unknown>(condition: (value: T, values?: Values) => boolean, validator: Validator<T, Values>): Validator<T, Values>

Conditional validator (only validates if condition is true)

ParameterTypeDescription
condition
(value: T, values?: Values) => boolean- Function that returns true if validation should run
validator
Validator<T, Values>- Validator to run conditionally
custom
function custom<T, Values = unknown>(validate: (value: T, values?: Values) => string | null | Promise<string | null>): Validator<T, Values>

Create custom validator

ParameterTypeDescription
validate
(value: T, values?: Values) => string | null | Promise<string | null>- Validation function
test
function test<T, Values = unknown>(test: (value: T, values?: Values) => boolean | Promise<boolean>, message: string): Validator<T, Values>

Test validator (custom test function)

ParameterTypeDescription
test
(value: T, values?: Values) => boolean | Promise<boolean>- Test function (returns true if valid)
message
string- Error message
oneOf
function oneOf<T, Values = unknown>(values: T[], message?: string): Validator<T, Values>

One of validator (value must be in list)

ParameterTypeDescription
values
T[]- Allowed values
messageoptional
string- Custom error message
notOneOf
function notOneOf<T, Values = unknown>(values: T[], message?: string): Validator<T, Values>

Not one of validator (value must NOT be in list)

ParameterTypeDescription
values
T[]- Disallowed values
messageoptional
string- Custom error message
equals
function equals<T, Values = unknown>(expected: T, message?: string): Validator<T, Values>

Equals validator (value must equal expected)

ParameterTypeDescription
expected
T- Expected value
messageoptional
string- Custom error message
notEquals
function notEquals<T, Values = unknown>(notExpected: T, message?: string): Validator<T, Values>

Not equals validator (value must NOT equal expected)

ParameterTypeDescription
notExpected
T- Value to avoid
messageoptional
string- Custom error message
debounce
function debounce<T extends (...args: any[]) => Promise<any>>(fn: T, wait: number): T & {
    cancel: () => void;
}

Debounce function

ParameterTypeDescription
fn
T- Function to debounce
wait
number- Milliseconds to wait
debounceValidator
function debounceValidator<T>(validator: (value: T) => Promise<string | null>, wait?: number): (value: T) => Promise<string | null>

Create a debounced validator

ParameterTypeDescription
validator
(value: T) => Promise<string | null>- Async validator function
waitoptional
number- Debounce delay in milliseconds (default: 300ms)

Variables

index_alphatypeof alpha

Tree-shakeable validators Import only what you need: ```ts import { required, email, min, max } from '@lpm.dev/neo.react-forms/validators' ``` Or import from specific categories: ```ts import { required, email } from '@lpm.dev/neo.react-forms/validators/string' import { min, max } from '@lpm.dev/neo.react-forms/validators/number' ```

index_alphanumerictypeof alphanumeric
index_betweentypeof between
index_composetypeof compose
index_containstypeof contains
index_customtypeof custom
index_debouncetypeof debounce
index_debounceValidatortypeof debounceValidator
index_emailtypeof email
index_endsWithtypeof endsWith
index_equalstypeof equals
index_eventypeof even
index_finitetypeof finite
index_integertypeof integer
index_lowercasetypeof lowercase
index_maxtypeof max
index_maxLengthtypeof maxLength
index_mintypeof min
index_minLengthtypeof minLength
index_multipleOftypeof multipleOf
index_negativetypeof negative
index_nonNegativetypeof nonNegative
index_nonPositivetypeof nonPositive
index_notEqualstypeof notEquals
index_notOneOftypeof notOneOf
index_oddtypeof odd
index_oneOftypeof oneOf
index_optionaltypeof optional
index_patterntypeof pattern
index_positivetypeof positive
index_requiredtypeof required
index_safeIntegertypeof safeInteger
index_startsWithtypeof startsWith
index_testtypeof test
index_trimmedtypeof trimmed
index_uppercasetypeof uppercase
index_urltypeof url
index_whentypeof when

dist/index-BzVbBKH3

Functions

required
function required(message?: string): Validator<string>

Required field validator

ParameterTypeDescription
messageoptional
string- Custom error message
email
function email(message?: string): Validator<string>

Email validator

ParameterTypeDescription
messageoptional
string- Custom error message
url
function url(message?: string): Validator<string>

URL validator

ParameterTypeDescription
messageoptional
string- Custom error message
minLength
function minLength(min: number, message?: string): Validator<string>

Minimum length validator

ParameterTypeDescription
min
number- Minimum length
messageoptional
string- Custom error message
maxLength
function maxLength(max: number, message?: string): Validator<string>

Maximum length validator

ParameterTypeDescription
max
number- Maximum length
messageoptional
string- Custom error message
pattern
function pattern(pattern: RegExp, message?: string): Validator<string>

Pattern validator (regex)

ParameterTypeDescription
pattern
RegExp- Regular expression
messageoptional
string- Custom error message
alphanumeric
function alphanumeric(message?: string): Validator<string>

Alphanumeric validator (letters and numbers only)

ParameterTypeDescription
messageoptional
string- Custom error message
alpha
function alpha(message?: string): Validator<string>

Alpha validator (letters only)

ParameterTypeDescription
messageoptional
string- Custom error message
lowercase
function lowercase(message?: string): Validator<string>

Lowercase validator

ParameterTypeDescription
messageoptional
string- Custom error message
uppercase
function uppercase(message?: string): Validator<string>

Uppercase validator

ParameterTypeDescription
messageoptional
string- Custom error message
trimmed
function trimmed(message?: string): Validator<string>

Trim validator (no leading/trailing whitespace)

ParameterTypeDescription
messageoptional
string- Custom error message
contains
function contains(substring: string, message?: string): Validator<string>

Contains validator (must include substring)

ParameterTypeDescription
substring
string- Substring to check for
messageoptional
string- Custom error message
startsWith
function startsWith(prefix: string, message?: string): Validator<string>

Starts with validator

ParameterTypeDescription
prefix
string- Prefix to check for
messageoptional
string- Custom error message
endsWith
function endsWith(suffix: string, message?: string): Validator<string>

Ends with validator

ParameterTypeDescription
suffix
string- Suffix to check for
messageoptional
string- Custom error message
min
function min(minValue: number, message?: string): Validator<number>

Minimum value validator

ParameterTypeDescription
minValue
number- Minimum allowed value
messageoptional
string- Custom error message
max
function max(maxValue: number, message?: string): Validator<number>

Maximum value validator

ParameterTypeDescription
maxValue
number- Maximum allowed value
messageoptional
string- Custom error message
between
function between(minValue: number, maxValue: number, message?: string): Validator<number>

Range validator (between min and max)

ParameterTypeDescription
minValue
number- Minimum value
maxValue
number- Maximum value
messageoptional
string- Custom error message
integer
function integer(message?: string): Validator<number>

Integer validator

ParameterTypeDescription
messageoptional
string- Custom error message
positive
function positive(message?: string): Validator<number>

Positive number validator (> 0)

ParameterTypeDescription
messageoptional
string- Custom error message
negative
function negative(message?: string): Validator<number>

Negative number validator (< 0)

ParameterTypeDescription
messageoptional
string- Custom error message
nonNegative
function nonNegative(message?: string): Validator<number>

Non-negative validator (>= 0)

ParameterTypeDescription
messageoptional
string- Custom error message
nonPositive
function nonPositive(message?: string): Validator<number>

Non-positive validator (<= 0)

ParameterTypeDescription
messageoptional
string- Custom error message
safeInteger
function safeInteger(message?: string): Validator<number>

Safe integer validator (within Number.MIN_SAFE_INTEGER and Number.MAX_SAFE_INTEGER)

ParameterTypeDescription
messageoptional
string- Custom error message
finite
function finite(message?: string): Validator<number>

Finite number validator (not Infinity or NaN)

ParameterTypeDescription
messageoptional
string- Custom error message
multipleOf
function multipleOf(divisor: number, message?: string): Validator<number>

Multiple of validator (divisible by)

ParameterTypeDescription
divisor
number- The number to divide by
messageoptional
string- Custom error message
even
function even(message?: string): Validator<number>

Even number validator

ParameterTypeDescription
messageoptional
string- Custom error message
odd
function odd(message?: string): Validator<number>

Odd number validator

ParameterTypeDescription
messageoptional
string- Custom error message
compose
function compose<T, Values = unknown>(validators: Validator<T, Values>[]): Validator<T, Values>

Compose multiple validators (runs all, returns first error)

ParameterTypeDescription
validators
Validator<T, Values>[]- Array of validators to compose
optional
function optional<T, Values = unknown>(validator: Validator<T, Values>): Validator<T | null | undefined, Values>

Optional validator (only validates if value exists)

ParameterTypeDescription
validator
Validator<T, Values>- Validator to make optional
when
function when<T, Values = unknown>(condition: (value: T, values?: Values) => boolean, validator: Validator<T, Values>): Validator<T, Values>

Conditional validator (only validates if condition is true)

ParameterTypeDescription
condition
(value: T, values?: Values) => boolean- Function that returns true if validation should run
validator
Validator<T, Values>- Validator to run conditionally
custom
function custom<T, Values = unknown>(validate: (value: T, values?: Values) => string | null | Promise<string | null>): Validator<T, Values>

Create custom validator

ParameterTypeDescription
validate
(value: T, values?: Values) => string | null | Promise<string | null>- Validation function
test
function test<T, Values = unknown>(test: (value: T, values?: Values) => boolean | Promise<boolean>, message: string): Validator<T, Values>

Test validator (custom test function)

ParameterTypeDescription
test
(value: T, values?: Values) => boolean | Promise<boolean>- Test function (returns true if valid)
message
string- Error message
oneOf
function oneOf<T, Values = unknown>(values: T[], message?: string): Validator<T, Values>

One of validator (value must be in list)

ParameterTypeDescription
values
T[]- Allowed values
messageoptional
string- Custom error message
notOneOf
function notOneOf<T, Values = unknown>(values: T[], message?: string): Validator<T, Values>

Not one of validator (value must NOT be in list)

ParameterTypeDescription
values
T[]- Disallowed values
messageoptional
string- Custom error message
equals
function equals<T, Values = unknown>(expected: T, message?: string): Validator<T, Values>

Equals validator (value must equal expected)

ParameterTypeDescription
expected
T- Expected value
messageoptional
string- Custom error message
notEquals
function notEquals<T, Values = unknown>(notExpected: T, message?: string): Validator<T, Values>

Not equals validator (value must NOT equal expected)

ParameterTypeDescription
notExpected
T- Value to avoid
messageoptional
string- Custom error message
debounce
function debounce<T extends (...args: any[]) => Promise<any>>(fn: T, wait: number): T & {
    cancel: () => void;
}

Debounce function

ParameterTypeDescription
fn
T- Function to debounce
wait
number- Milliseconds to wait
debounceValidator
function debounceValidator<T>(validator: (value: T) => Promise<string | null>, wait?: number): (value: T) => Promise<string | null>

Create a debounced validator

ParameterTypeDescription
validator
(value: T) => Promise<string | null>- Async validator function
waitoptional
number- Debounce delay in milliseconds (default: 300ms)

Variables

index_alphatypeof alpha

Tree-shakeable validators Import only what you need: ```ts import { required, email, min, max } from '@lpm.dev/neo.react-forms/validators' ``` Or import from specific categories: ```ts import { required, email } from '@lpm.dev/neo.react-forms/validators/string' import { min, max } from '@lpm.dev/neo.react-forms/validators/number' ```

index_alphanumerictypeof alphanumeric
index_betweentypeof between
index_composetypeof compose
index_containstypeof contains
index_customtypeof custom
index_debouncetypeof debounce
index_debounceValidatortypeof debounceValidator
index_emailtypeof email
index_endsWithtypeof endsWith
index_equalstypeof equals
index_eventypeof even
index_finitetypeof finite
index_integertypeof integer
index_lowercasetypeof lowercase
index_maxtypeof max
index_maxLengthtypeof maxLength
index_mintypeof min
index_minLengthtypeof minLength
index_multipleOftypeof multipleOf
index_negativetypeof negative
index_nonNegativetypeof nonNegative
index_nonPositivetypeof nonPositive
index_notEqualstypeof notEquals
index_notOneOftypeof notOneOf
index_oddtypeof odd
index_oneOftypeof oneOf
index_optionaltypeof optional
index_patterntypeof pattern
index_positivetypeof positive
index_requiredtypeof required
index_safeIntegertypeof safeInteger
index_startsWithtypeof startsWith
index_testtypeof test
index_trimmedtypeof trimmed
index_uppercasetypeof uppercase
index_urltypeof url
index_whentypeof when

dist/index-CK1rLQVa

Functions

configureDebug
function configureDebug(config: Partial<DebugConfig>): void

Configure debug mode

ParameterTypeDescription
config
Partial<DebugConfig>- Debug configuration
getDebugConfig
function getDebugConfig(): DebugConfig

Get current debug configuration

debugValueChange
function debugValueChange(formId: string, fieldName: string, oldValue: any, newValue: any): void

Log field value change

ParameterTypeDescription
formId
string
fieldName
string
oldValue
any
newValue
any
debugValidation
function debugValidation(formId: string, fieldName: string, result: {
    valid: boolean;
    error?: string;
    duration: number;
}): void

Log validation run

ParameterTypeDescription
formId
string
fieldName
string
result
{ valid: boolean; error?: string; duration: number; }
debugSubmission
function debugSubmission(formId: string, result: {
    success: boolean;
    duration: number;
    error?: any;
}): void

Log form submission

ParameterTypeDescription
formId
string
result
{ success: boolean; duration: number; error?: any; }
debugStateUpdate
function debugStateUpdate(formId: string, fieldName: string, state: {
    touched?: boolean;
    dirty?: boolean;
    error?: string;
}): void

Log field state update

ParameterTypeDescription
formId
string
fieldName
string
state
{ touched?: boolean; dirty?: boolean; error?: string; }
debugFormCreated
function debugFormCreated(formId: string, initialValues: any): void

Log form creation

ParameterTypeDescription
formId
string
initialValues
any
createFormId
function createFormId(customId?: string): string
ParameterTypeDescription
customIdoptional
string
debugFormState
function debugFormState(formId: string, state: any): void

Log form state snapshot (useful for debugging)

ParameterTypeDescription
formId
string
state
any
createTimer
function createTimer(): () => number

Performance timer utility

getFieldAriaProps
function getFieldAriaProps(options: {
    name: string;
    hasError?: boolean;
    isRequired?: boolean;
    errorId?: string;
    descriptionId?: string;
}): A11yFieldProps

Generate ARIA attributes for a form field

ParameterTypeDescription
options
{ name: string; hasError?: boolean; isRequired?: boolean; errorId?: string; descriptionId?: string; }- Field state and configuration
generateFieldIds
function generateFieldIds(fieldName: string): {
    errorId: string;
    descriptionId: string;
}

Generate unique IDs for error and description elements

ParameterTypeDescription
fieldName
string- Field name
getLabelProps
function getLabelProps(fieldName: string, labelText?: string): {
    htmlFor: string;
    children?: string;
}

Get accessible label props

ParameterTypeDescription
fieldName
string- Field name
labelTextoptional
string- Label text
getErrorProps
function getErrorProps(fieldName: string, error?: string): {
    id: string;
    role: 'alert';
    'aria-live': 'polite';
    children?: string;
}

Get accessible error message props

ParameterTypeDescription
fieldName
string- Field name
erroroptional
string- Error message
getDescriptionProps
function getDescriptionProps(fieldName: string, description?: string): {
    id: string;
    children?: string;
}

Get accessible description props

ParameterTypeDescription
fieldName
string- Field name
descriptionoptional
string- Description text
announceToScreenReader
function announceToScreenReader(message: string, priority?: 'polite' | 'assertive'): void

Announce message to screen readers

ParameterTypeDescription
message
string- Message to announce
priorityoptional
'polite' | 'assertive'- Announcement priority ('polite' or 'assertive')
announceValidationError
function announceValidationError(fieldName: string, error: string): void

Validation error announcer for screen readers

ParameterTypeDescription
fieldName
string
error
string
announceFormSubmission
function announceFormSubmission(success: boolean, message?: string): void

Form submission announcer for screen readers

ParameterTypeDescription
success
boolean
messageoptional
string
enhanceErrorMessage
function enhanceErrorMessage(error: string): EnhancedError

Enhance an error message with suggestions

ParameterTypeDescription
error
string- Original error message
formatError
function formatError(error: string | EnhancedError, format?: 'message' | 'suggestion' | 'full'): string

Format error message with suggestion

ParameterTypeDescription
error
string | EnhancedError- Error message or enhanced error
formatoptional
'message' | 'suggestion' | 'full'- Format type
createValidationError
function createValidationError(message: string, suggestion?: string, code?: string): EnhancedError

Create a validation error with suggestion

ParameterTypeDescription
message
string- Error message
suggestionoptional
string- Helpful suggestion
codeoptional
string- Error code
createFormSnapshot
function createFormSnapshot<Values extends Record<string, unknown>>(formState: FormState<Values>, initialValues: Values): FormSnapshot<Values>

Create a form state snapshot for DevTools inspection

ParameterTypeDescription
formState
FormState<Values>- Current form state
initialValues
Values- Initial form values (for dirty detection)
logFormState
function logFormState<Values extends Record<string, unknown>>(formId: string, snapshot: FormSnapshot<Values>): void

Log form state to console in a developer-friendly format

ParameterTypeDescription
formId
string- Form identifier
snapshot
FormSnapshot<Values>- Form snapshot
exposeFormToWindow
function exposeFormToWindow<Values extends Record<string, unknown>>(formId: string, snapshot: FormSnapshot<Values>): void

Expose form state to window for DevTools access

ParameterTypeDescription
formId
string- Form identifier
snapshot
FormSnapshot<Values>- Form snapshot
diffFormState
function diffFormState<Values extends Record<string, unknown>>(before: FormSnapshot<Values>, after: FormSnapshot<Values>): {
    changedFields: string[];
    newErrors: Partial<Record<Path<Values>, string>>;
    clearedErrors: string[];
    touchedFields: string[];
}

Create a form state diff between two snapshots

ParameterTypeDescription
before
FormSnapshot<Values>- Previous snapshot
after
FormSnapshot<Values>- Current snapshot
createPerformanceMonitor
function createPerformanceMonitor(): {
    startTimer: (operation: string) => () => void;
    getMetrics: () => Record<string, number>;
    logMetrics: () => void;
}

Create performance monitor for a form

Variables

ErrorMessages{ readonly required: (fieldName?: string) => string; readonly email: "Please enter a valid email address"; readonly emailRequired: "Email address is required"; readonly passwordTooShort: (minLength: number) => string; readonly passwordsMatch: "Passwords must match"; readonly passwordWeak: "Password must include uppercase, lowercase, number, and special character"; readonly minNumber: (min: number) => string; readonly maxNumber: (max: number) => string; readonly numberBetween: (min: number, max: number) => string; readonly minLength: (min: number) => string; readonly maxLength: (max: number) => string; readonly url: "Please enter a valid URL (e.g., https://example.com)"; readonly phone: "Please enter a valid phone number"; readonly date: "Please enter a valid date"; readonly dateAfter: (date: string) => string; readonly dateBefore: (date: string) => string; readonly invalid: (fieldName?: string) => string; }

Common error messages (pre-defined for consistency)

index_ErrorMessagestypeof ErrorMessages
index_announceFormSubmissiontypeof announceFormSubmission
index_announceToScreenReadertypeof announceToScreenReader
index_announceValidationErrortypeof announceValidationError
index_configureDebugtypeof configureDebug
index_createFormIdtypeof createFormId
index_createFormSnapshottypeof createFormSnapshot
index_createPerformanceMonitortypeof createPerformanceMonitor
index_createTimertypeof createTimer
index_createValidationErrortypeof createValidationError
index_debugFormCreatedtypeof debugFormCreated
index_debugFormStatetypeof debugFormState
index_debugStateUpdatetypeof debugStateUpdate
index_debugSubmissiontypeof debugSubmission
index_debugValidationtypeof debugValidation
index_debugValueChangetypeof debugValueChange
index_diffFormStatetypeof diffFormState
index_enhanceErrorMessagetypeof enhanceErrorMessage
index_exposeFormToWindowtypeof exposeFormToWindow
index_formatErrortypeof formatError
index_generateFieldIdstypeof generateFieldIds
index_getDebugConfigtypeof getDebugConfig
index_getDescriptionPropstypeof getDescriptionProps
index_getErrorPropstypeof getErrorProps
index_getFieldAriaPropstypeof getFieldAriaProps
index_getLabelPropstypeof getLabelProps
index_logFormStatetypeof logFormState

dist/index-DcOeuAnw

Functions

configureDebug
function configureDebug(config: Partial<DebugConfig>): void

Configure debug mode

ParameterTypeDescription
config
Partial<DebugConfig>- Debug configuration
getDebugConfig
function getDebugConfig(): DebugConfig

Get current debug configuration

debugValueChange
function debugValueChange(formId: string, fieldName: string, oldValue: any, newValue: any): void

Log field value change

ParameterTypeDescription
formId
string
fieldName
string
oldValue
any
newValue
any
debugValidation
function debugValidation(formId: string, fieldName: string, result: {
    valid: boolean;
    error?: string;
    duration: number;
}): void

Log validation run

ParameterTypeDescription
formId
string
fieldName
string
result
{ valid: boolean; error?: string; duration: number; }
debugSubmission
function debugSubmission(formId: string, result: {
    success: boolean;
    duration: number;
    error?: any;
}): void

Log form submission

ParameterTypeDescription
formId
string
result
{ success: boolean; duration: number; error?: any; }
debugStateUpdate
function debugStateUpdate(formId: string, fieldName: string, state: {
    touched?: boolean;
    dirty?: boolean;
    error?: string;
}): void

Log field state update

ParameterTypeDescription
formId
string
fieldName
string
state
{ touched?: boolean; dirty?: boolean; error?: string; }
debugFormCreated
function debugFormCreated(formId: string, initialValues: any): void

Log form creation

ParameterTypeDescription
formId
string
initialValues
any
createFormId
function createFormId(customId?: string): string
ParameterTypeDescription
customIdoptional
string
debugFormState
function debugFormState(formId: string, state: any): void

Log form state snapshot (useful for debugging)

ParameterTypeDescription
formId
string
state
any
createTimer
function createTimer(): () => number

Performance timer utility

getFieldAriaProps
function getFieldAriaProps(options: {
    name: string;
    hasError?: boolean;
    isRequired?: boolean;
    errorId?: string;
    descriptionId?: string;
}): A11yFieldProps

Generate ARIA attributes for a form field

ParameterTypeDescription
options
{ name: string; hasError?: boolean; isRequired?: boolean; errorId?: string; descriptionId?: string; }- Field state and configuration
generateFieldIds
function generateFieldIds(fieldName: string): {
    errorId: string;
    descriptionId: string;
}

Generate unique IDs for error and description elements

ParameterTypeDescription
fieldName
string- Field name
getLabelProps
function getLabelProps(fieldName: string, labelText?: string): {
    htmlFor: string;
    children?: string;
}

Get accessible label props

ParameterTypeDescription
fieldName
string- Field name
labelTextoptional
string- Label text
getErrorProps
function getErrorProps(fieldName: string, error?: string): {
    id: string;
    role: 'alert';
    'aria-live': 'polite';
    children?: string;
}

Get accessible error message props

ParameterTypeDescription
fieldName
string- Field name
erroroptional
string- Error message
getDescriptionProps
function getDescriptionProps(fieldName: string, description?: string): {
    id: string;
    children?: string;
}

Get accessible description props

ParameterTypeDescription
fieldName
string- Field name
descriptionoptional
string- Description text
announceToScreenReader
function announceToScreenReader(message: string, priority?: 'polite' | 'assertive'): void

Announce message to screen readers

ParameterTypeDescription
message
string- Message to announce
priorityoptional
'polite' | 'assertive'- Announcement priority ('polite' or 'assertive')
announceValidationError
function announceValidationError(fieldName: string, error: string): void

Validation error announcer for screen readers

ParameterTypeDescription
fieldName
string
error
string
announceFormSubmission
function announceFormSubmission(success: boolean, message?: string): void

Form submission announcer for screen readers

ParameterTypeDescription
success
boolean
messageoptional
string
enhanceErrorMessage
function enhanceErrorMessage(error: string): EnhancedError

Enhance an error message with suggestions

ParameterTypeDescription
error
string- Original error message
formatError
function formatError(error: string | EnhancedError, format?: 'message' | 'suggestion' | 'full'): string

Format error message with suggestion

ParameterTypeDescription
error
string | EnhancedError- Error message or enhanced error
formatoptional
'message' | 'suggestion' | 'full'- Format type
createValidationError
function createValidationError(message: string, suggestion?: string, code?: string): EnhancedError

Create a validation error with suggestion

ParameterTypeDescription
message
string- Error message
suggestionoptional
string- Helpful suggestion
codeoptional
string- Error code
createFormSnapshot
function createFormSnapshot<Values extends Record<string, unknown>>(formState: FormState<Values>, initialValues: Values): FormSnapshot<Values>

Create a form state snapshot for DevTools inspection

ParameterTypeDescription
formState
FormState<Values>- Current form state
initialValues
Values- Initial form values (for dirty detection)
logFormState
function logFormState<Values extends Record<string, unknown>>(formId: string, snapshot: FormSnapshot<Values>): void

Log form state to console in a developer-friendly format

ParameterTypeDescription
formId
string- Form identifier
snapshot
FormSnapshot<Values>- Form snapshot
exposeFormToWindow
function exposeFormToWindow<Values extends Record<string, unknown>>(formId: string, snapshot: FormSnapshot<Values>): void

Expose form state to window for DevTools access

ParameterTypeDescription
formId
string- Form identifier
snapshot
FormSnapshot<Values>- Form snapshot
diffFormState
function diffFormState<Values extends Record<string, unknown>>(before: FormSnapshot<Values>, after: FormSnapshot<Values>): {
    changedFields: string[];
    newErrors: Partial<Record<Path<Values>, string>>;
    clearedErrors: string[];
    touchedFields: string[];
}

Create a form state diff between two snapshots

ParameterTypeDescription
before
FormSnapshot<Values>- Previous snapshot
after
FormSnapshot<Values>- Current snapshot
createPerformanceMonitor
function createPerformanceMonitor(): {
    startTimer: (operation: string) => () => void;
    getMetrics: () => Record<string, number>;
    logMetrics: () => void;
}

Create performance monitor for a form

Variables

ErrorMessages{ readonly required: (fieldName?: string) => string; readonly email: "Please enter a valid email address"; readonly emailRequired: "Email address is required"; readonly passwordTooShort: (minLength: number) => string; readonly passwordsMatch: "Passwords must match"; readonly passwordWeak: "Password must include uppercase, lowercase, number, and special character"; readonly minNumber: (min: number) => string; readonly maxNumber: (max: number) => string; readonly numberBetween: (min: number, max: number) => string; readonly minLength: (min: number) => string; readonly maxLength: (max: number) => string; readonly url: "Please enter a valid URL (e.g., https://example.com)"; readonly phone: "Please enter a valid phone number"; readonly date: "Please enter a valid date"; readonly dateAfter: (date: string) => string; readonly dateBefore: (date: string) => string; readonly invalid: (fieldName?: string) => string; }

Common error messages (pre-defined for consistency)

index_ErrorMessagestypeof ErrorMessages
index_announceFormSubmissiontypeof announceFormSubmission
index_announceToScreenReadertypeof announceToScreenReader
index_announceValidationErrortypeof announceValidationError
index_configureDebugtypeof configureDebug
index_createFormIdtypeof createFormId
index_createFormSnapshottypeof createFormSnapshot
index_createPerformanceMonitortypeof createPerformanceMonitor
index_createTimertypeof createTimer
index_createValidationErrortypeof createValidationError
index_debugFormCreatedtypeof debugFormCreated
index_debugFormStatetypeof debugFormState
index_debugStateUpdatetypeof debugStateUpdate
index_debugSubmissiontypeof debugSubmission
index_debugValidationtypeof debugValidation
index_debugValueChangetypeof debugValueChange
index_diffFormStatetypeof diffFormState
index_enhanceErrorMessagetypeof enhanceErrorMessage
index_exposeFormToWindowtypeof exposeFormToWindow
index_formatErrortypeof formatError
index_generateFieldIdstypeof generateFieldIds
index_getDebugConfigtypeof getDebugConfig
index_getDescriptionPropstypeof getDescriptionProps
index_getErrorPropstypeof getErrorProps
index_getFieldAriaPropstypeof getFieldAriaProps
index_getLabelPropstypeof getLabelProps
index_logFormStatetypeof logFormState

dist

Functions

useForm
function useForm<Values extends Record<string, unknown>>(options: UseFormOptions<Values>): UseFormReturn<Values>

Main useForm hook

ParameterTypeDescription
options
UseFormOptions<Values>

dist/types-Cd70yggL

Functions

getValueByPath
function getValueByPath<T>(obj: T, path: string): unknown

Get value at a nested path

ParameterTypeDescription
obj
T- Object to get value from
path
string- Dot-separated path (e.g., "user.profile.name")
setValueByPath
function setValueByPath<T>(obj: T, path: string, value: unknown): T

Set value at a nested path (immutably)

ParameterTypeDescription
obj
T- Object to set value in
path
string- Dot-separated path
value
unknown- Value to set

Classes

FormStore

Form state store Manages form state with field-level subscription support. This enables isolated re-renders - only components that subscribe to a specific field will re-render when that field changes.

constructor(initialValues: Values, computed?: Partial<Record<keyof Values, (values: Values) => unknown>>)
MethodReturn TypeDescription
getVersion()numberGet current version (for useSyncExternalStore)
getValues()ValuesGet current form values
getValue(name)ValueAtPath<Values, P>Get value at specific field path
setValue(name, value)voidSet value at specific field path
getError(name)string | undefinedGet error for specific field
setError(name, error)voidSet error for specific field
getTouched(name)booleanGet touched state for specific field
setTouched(name, touched)voidSet touched state for specific field
getFieldState(name)FieldState<ValueAtPath<Values, P>>Get complete field state
subscribe(name, callback)UnsubscribeSubscribe to field changes Returns unsubscribe function
subscribeToStore(callback)() => voidSubscribe to any store change (for form-level re-renders)
startValidation(name)AbortControllerStart async validation for a field
endValidation(name)voidEnd async validation for a field
cancelValidation(name)voidCancel pending validation for a field
isFieldValidating(name)booleanCheck if a specific field is validating
isValidating()booleanCheck if any field is validating
getValidatingFields()string[]Get all fields currently validating
reset(newInitialValues)voidReset form to initial values
getErrors()Partial<Record<Path<Values>, string>>Get all errors
getTouchedFields()Partial<Record<Path<Values>, boolean>>Get all touched fields
isDirty()booleanCheck if form is dirty (any field changed)
isValid()booleanCheck if form is valid (no errors)

dist/types-Cd70yggL

Functions

getValueByPath
function getValueByPath<T>(obj: T, path: string): unknown

Get value at a nested path

ParameterTypeDescription
obj
T- Object to get value from
path
string- Dot-separated path (e.g., "user.profile.name")
setValueByPath
function setValueByPath<T>(obj: T, path: string, value: unknown): T

Set value at a nested path (immutably)

ParameterTypeDescription
obj
T- Object to set value in
path
string- Dot-separated path
value
unknown- Value to set

Classes

FormStore

Form state store Manages form state with field-level subscription support. This enables isolated re-renders - only components that subscribe to a specific field will re-render when that field changes.

constructor(initialValues: Values, computed?: Partial<Record<keyof Values, (values: Values) => unknown>>)
MethodReturn TypeDescription
getVersion()numberGet current version (for useSyncExternalStore)
getValues()ValuesGet current form values
getValue(name)ValueAtPath<Values, P>Get value at specific field path
setValue(name, value)voidSet value at specific field path
getError(name)string | undefinedGet error for specific field
setError(name, error)voidSet error for specific field
getTouched(name)booleanGet touched state for specific field
setTouched(name, touched)voidSet touched state for specific field
getFieldState(name)FieldState<ValueAtPath<Values, P>>Get complete field state
subscribe(name, callback)UnsubscribeSubscribe to field changes Returns unsubscribe function
subscribeToStore(callback)() => voidSubscribe to any store change (for form-level re-renders)
startValidation(name)AbortControllerStart async validation for a field
endValidation(name)voidEnd async validation for a field
cancelValidation(name)voidCancel pending validation for a field
isFieldValidating(name)booleanCheck if a specific field is validating
isValidating()booleanCheck if any field is validating
getValidatingFields()string[]Get all fields currently validating
reset(newInitialValues)voidReset form to initial values
getErrors()Partial<Record<Path<Values>, string>>Get all errors
getTouchedFields()Partial<Record<Path<Values>, boolean>>Get all touched fields
isDirty()booleanCheck if form is dirty (any field changed)
isValid()booleanCheck if form is valid (no errors)
Unlimited AccessInstall as many Pool packages as you need.
Fund Real WorkEvery install you run sends revenue directly to the developer who built it.

Taxes calculated at checkout based on your location.

LicenseMIT
Size599.44 KB
Files37
Node version>= 18
TypeScriptYes