Formify Docs

URL

Validate http, https, and ftp URLs

URL

The url rule checks that a value is a valid absolute URL with an explicit scheme.

What it checks

A string starting with http://, https://, or ftp://, followed by a non-empty host, with no whitespace:

/^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/i

Config flag

validationSchema: {
  website: { url: true },
}

With a custom message:

website: { url: "Enter a valid URL" }

V builder

import { V } from "formify-js";

V.url()                    // default message
V.url("Enter a valid URL")

Default message

Please enter a valid URL

Things to know

  • Empty values pass unless required: true is also set.
  • Only http, https, and ftp schemes are accepted — protocol-relative URLs (//example.com) fail.

On this page