Skip to content
WingoUI
ComponentsTemplatesDocsPricingAI agentsBlogChangelogContact
Components
Buttons & Actions
ButtonButton GroupCopy ButtonDelete ButtonTheme ToggleToggleToggle Group
Inputs
Avatar UploadCalendarCheckboxColor PickerComboboxCountry SelectCron PickerCurrency InputDate PickerDate Range PickerDate Time PickerDuration PickerEmail InputEmoji PickerFile UploadFilter BuilderInputInput GroupListboxMasked InputMention InputMonth PickerMulti SelectNumber InputOTP InputPassword InputPhone InputRadio GroupRatingSearch InputSegmented ControlSelectSignature PadSliderSwitchTag InputTextareaTime PickerTimezone SelectTree Select
Forms
Address InputBooking WidgetCSV ImportFieldForm WizardInline EditInvoice line itemsRich Text EditorSchema Builder
Navigation
Back To TopBounce SidebarBreadcrumbCommand MenuGlobal SearchGooey NavHook SidebarNav MenuNav TabsPaginationProximity SidebarScroll ProgressSidebarStepsTable Of ContentsTabsTopbarUser MenuWorkspace Switcher
Overlays
Alert DialogContext MenuDialogDrawerDropdown MenuFamily DrawerHover CardPopoverShare DialogSheetShortcuts DialogTooltipTour
Feedback
AlertBannerCookie ConsentEmoji ReactionEmpty StateNotification BellNotification CenterProgressRoute ProgressSetup ChecklistSkeletonSpinnerToast
Data Display
Approval FlowAvatarBadgeCalendar ViewCode BlockComment ThreadContact cardCountdownDescription ListDiff ViewerFile ListFile managerFolderGanttJSON ViewerKbdLog ViewerMarkdownPresenceSchedulerTagTimelineTree View
Tables & Lists
Audit LogData TableDeal PipelineEditable GridKanbanListMembers tablePermissions MatrixTableTask ListVirtual List
Charts & Stats
Animated CounterArea chartBar chartDonut chartFunnel chartGaugeGitHub ActivityHeatmap calendarLeaderboardLine chartRadar chartRadial barSparklineStat CardTrackerTrend badge
Layout
AccordionApp ShellCardCollapsibleDetail LayoutEntity HeaderPage HeaderScroll AreaSeparatorSettings LayoutSplit ViewToolbar
Media
Audio PlayerCarouselCSV ViewerDOCX EditorDOCX ViewerExcel ViewerFile SystemImage compareImage CropperImage GalleryImage LightboxLocation MapPDF ViewerPowerPoint ViewerQR CodeStep PlayerVideo Player
AI Kit
Agent Status CardChat MessageChat ThreadChat WidgetConversation ListFluid OrbGrid RevealMatrix OrbModel PickerPrompt InputReasoning IndicatorRule BuilderSuggestion ChipsTool Call TimelineUsage MeterVoice InputWorkflow Canvas
Text & Effects
Background PatternGravity LettersMarqueeTerminalText AnimateText Rotate
Mobile
Action SheetBottom Tab BarFABHaptic ButtonHero HeaderInstall PromptLarge Title HeaderNotification BannerOnboarding CarouselPicker WheelPull To RefreshSlide To ConfirmSticky CTA BarSwipe DeckSwipeable Tabs
Commerce
Cart drawerCategory pickerCheckout stepsCoupon inputFavorite buttonFilter panelListing cardListing gridOrder trackerPricePrice rangePricing tableProduct galleryQuantity stepperReviewsSeller card
Marketing Sections
App Download SectionBlog Cards SectionCTA SectionFAQ SectionFeature GridFeature ShowcaseHero SectionIntegrations SectionLogo CloudMarketing FooterMarketing HeaderMarketing SectionNewsletter SectionPricing SectionStats SectionSteps SectionTeam SectionTestimonials SectionTimeline SectionVideo Section
Blocks
Admin Dashboard PageAdmin ShellAI Chat PageAPI Keys PageAutomation Builder PageCheckout PageCRM Contact PageCRM Pipeline PageError PagesInbox PageInvoice PageKPI DashboardListing Detail PageLogin PageMarketplace Home PageMarketplace Search PageMarketplace ShellMobile App HomeOnboarding FlowOrder History PagePost Listing WizardPricing PageProfile PageRegister PageSettings PageUsers Admin Page
Templates
About PageAcademy PageAccessibility PageAffiliate PageAgency PageAI Product PageAppointment Booking PageBlog PageBlog Post PageBug Bounty PageCareers PageChangelog PageCommunity PageCompare PageContact PageCustomer Story PageCustomers PageDemo Booking PageDevelopers PageDocs Home PageDownload PageEnterprise PageEvents PageExperts PageFAQ PageFeature PageGlossary PageHelp Article PageHelp Center PageHome Services PageImpact PageIntegration Detail PageIntegrations PageJob Detail PageLanding PageLaunch PageLegal PageManifesto PagePortfolio PagePress PageProduct Tour PagePromo PageReal Estate PageReferral PageResearch Report PageRestaurant PageRoadmap PageROI Calculator PageSecurity PageSolutions PageStartups PageStatus PageStorefront PageSwitch PageTemplate Gallery PageTravel PageWaitlist PageYear in Review Page
Hooks & Utilities
AI ChatChart kitCommerceDate utilsFile exportFile typesFiltersForm validationHapticsInvoicingMotion presetsNavigationNumber formatRelative timeRomanian locationsSpreadsheetText matchTonesUIProvideruseClipboarduseConsentuseControllableStateuseCooldownuseDebounceuseKeyboardInsetuseLocaleuseLongPressuseMediaControlsuseMediaQueryuseOverflowItemsusePersistedStateuseScrollEdgesuseScrollStateuseSelectionuseShortcutuseStickToBottom
GalleryTheme

Hooks & Utilities

Form validation

Hooks & Utilities

Form validation TypeScript helper for React

FiltersHaptics
Live props
Demo
messages
minLength8
minScore2
  1. Home
  2. Components
  3. Hooks & Utilities
  4. Form validation
Pro

Form validation TypeScript helper for React

v1.0.0·Added in 1.0.0

Zod validation rules for React forms with one message set (English or Romanian), react-hook-form glue and a pretend request.

Fill the sign-up form and leave a field: its error appears under it and clears as you fix it. Submit with empty fields and every error shows at once, focus jumps to the first one. Switch the messages to the ready Romanian set, raise the password length or the minimum strength and try again. A valid form sends a pretend request and shows the result.

Form validation is a Pro React helper in the React hooks and utilities category, written in TypeScript for React 19. It installs as source with npx wingo-ui@latest add form-validation, together with Invoicing and the npm packages react-hook-form, @hookform/resolvers, zod and libphonenumber-js.

Add to a project

Requirements: React 19, in Next.js (App Router or Pages), Vite or React Router. Installation guide · Next.js setup · Vite setup

npx wingo-ui@latest add form-validation

Form validation is part of Pro, with 298 more Pro items: $8 a month or $150 once. 14-day refund before you download any Pro item. See plans

Usage

Import createValidators from @/lib/form-validation.

import { z } from "zod"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { createValidators, fieldError, useZodForm } from "@/lib/form-validation"

// English messages by default; pass VALIDATION_MESSAGES_RO for the Romanian set
const v = createValidators()
const schema = z.object({ email: v.email(), cui: v.cui({ required: false }) })

export function CompanyForm({ onSave }: { onSave: (values: z.output<typeof schema>) => Promise<void> }) {
  const form = useZodForm(schema, { defaultValues: { email: "", cui: "" } })
  return (
    <form onSubmit={form.handleSubmit(onSave)} noValidate className="flex flex-col gap-4">
      <Input label="Email" type="email" autoComplete="email" {...form.register("email")} error={fieldError(form, "email")} />
      <Input label="Tax ID (CUI)" {...form.register("cui")} error={fieldError(form, "cui")} />
      <Button type="submit" loading={form.formState.isSubmitting}>Save</Button>
    </form>
  )
}

API

  • messagesdefault "en"
    "ro" | "en"

    Demo only: which message set the validators use (the English defaults or VALIDATION_MESSAGES_RO).

  • minLengthdefault 8
    number

    v.password({ minLength }): the shortest password accepted.

  • minScoredefault 2
    number

    v.password({ score: scorePassword, minScore }): the weakest strength accepted (0 skips the check, 4 is Strong).

  • createValidators
    (messages?: Partial<ValidationMessages>) => Validators

    Zod schemas sharing one message set: text({ required, min, max }), name(), email(), password({ minLength, score, minScore }), phone({ country }), cui(), iban(), postalCode(), url(), otp(length), accept() (a ticked checkbox), number({ min, max }). Every field rule takes { required } and accepts "" when optional. v.messages is the merged set.

  • withMatch
    (schema: ZodObject, field: string, confirmField: string, message?: string) => ZodType

    Adds "confirmField must equal field" to an object schema, reported on the confirm field (password and its confirmation).

  • useZodForm
    (schema: ZodType, options?: UseFormProps) => UseFormReturn

    useForm with the zod resolver and the library's timing: mode onTouched (an error appears once a field is left), then it updates as you type. Input and output types come from the schema.

  • fieldError
    (form: UseFormReturn, name: string) => string | undefined

    The error message of a field (dotted paths work), ready for a component's error prop: error={fieldError(form, "email")}.

  • simulateRequest
    <T>(ms?: number, options?: { fail?: string; value?: T; signal?: AbortSignal }) => Promise<T>

    A pretend request for demos and default handlers: resolves after ms (default 900), or rejects with fail as the message.

  • DEFAULT_VALIDATION_MESSAGES
    ValidationMessages

    The English default messages createValidators merges yours over. Counted messages are functions: tooShort(min), otp(length).

  • VALIDATION_MESSAGES_RO
    ValidationMessages

    The ready Romanian message set: pass it to createValidators for Romanian errors.

Examples

Bank details

IBAN and postal code rules; press Check to see the errors.

Dependencies

react-hook-form@hookform/resolverszodlibphonenumber-jsinvoicing

Files

  • lib/form-validation.ts

FAQ

Is the Form validation helper free?

The preview, props and docs are free; copying the source needs a Pro plan. See plans.

How do I install Form validation?

Run npx wingo-ui@latest add form-validation. It also adds the Wingo UI item it builds on (Invoicing) and the npm packages react-hook-form, @hookform/resolvers, zod and libphonenumber-js. With shadcn, add the @wingo-ui registry with your API key, then run npx shadcn@latest add @wingo-ui/form-validation.

See also

FieldInputPassword InputInvoicinglibuseCooldownhook

Used in

Onboarding FlowLogin PageAdmin ShellAutomation Builder PageCRM Contact PageCRM Pipeline PageError PagesInbox PageInvoice PagePost Listing WizardRegister PageSettings Page

More React hooks and utilities

HapticslibMotion presetslibNavigationlibNumber formatlibRelative timelibRomanian locationslib
All 36 React hooks and utilities

Articles using this component

  • React Multi Step Form with Zod, Saved Drafts and Motion

    Component guides · Oct 13, 2026 · 12 min read

  • React Phone Input With Country Code and E.164 Value

    Component guides · Oct 13, 2026 · 8 min read

  • IBAN Validation JavaScript: Mod 97, Regex and a React Field

    Component guides · Oct 9, 2026 · 12 min read

  • React Form Components: Accessible Fields, Zod and Mobile

    Component guides · Oct 9, 2026 · 26 min read

PreviousFiltersNext Haptics

Create an account

Example: +40 712 034 567

Optional

Password strength

v.password({ minLength: 8, minScore: 2 })