Formify Docs

regexVal (v1 Compatibility)

The legacy regex helpers from Formify v1, kept for backward compatibility

regexVal (v1 Compatibility)

regexVal is the v1 helper — a small set of pre-built regular-expression validators. It still works, but new code should prefer the V builder (or plain config flags).

Available helpers

import { regexVal } from "formify-js";

regexVal.min(6)               // min string length
regexVal.email()
regexVal.specialCharacters()
regexVal.url()
regexVal.phone()
regexVal.uuid()
regexVal.alpha()
regexVal.alphanumeric()
regexVal.numeric()
regexVal.integer()
regexVal.date()
regexVal.time()

With useFormValidator (v1 API)

regexVal rules slot into the v1-style validators array:

import useFormValidator, { regexVal } from "formify-js";

const formValidator = useFormValidator(
  { email: "", password: "" },
  {
    email: {
      required: true,
      requiredMessage: "Please enter Email",
      validators: [{ validator: regexVal.email(), message: "Invalid email" }],
    },
    password: {
      required: true,
      validators: [{ validator: regexVal.min(6), message: "Too short" }],
    },
  },
  (values) => console.log(values),
);

With the V builder

V-style rules work in the same validators array:

import { V } from "formify-js";

validators: [{ validator: V.email(), message: "Enter a valid email" }]

Migration note

New code should prefer the v2 APIs:

v1v2
regexVal.email()V.email() or { email: true }
regexVal.min(6)V.minLength(6) or { minLength: 6 }
regexVal.specialCharacters()V.specialCharacters() or { specialCharacters: true }
useFormValidator(...)useForm({ ... })

See Migration from v1 for the full upgrade path.

On this page