react-formbridge
Browse documentation
Field buildersv1.0.2

field.url()

String builder for URLs with a built-in HTTP/HTTPS format check.

  • A built-in URL format validator is wired through format(...) at construction time
  • Good for profile websites, callback URLs, portfolio links, or webhook endpoints
  • Override the built-in format with format() when you need stricter rules (e.g. HTTPS-only)
Url.tsxtsx
1const schema = { website: field.url('Website').optional().trim() }

Defaults, inheritance & field methods

  • defaultValue is ''
  • type is url
  • A built-in HTTP/HTTPS validator is wired through format(...) at construction time
  • The built-in format does the heavy lifting for the default case
  • Shared methods: see Base field builder
  • String builder methods: see field.text()

URL-specific methods:

MethodTypeDescription
--field.url() does not add methods beyond the shared string-builder surface; it mainly preconfigures an HTTP/HTTPS format validator.

Recipes

Patterns that showcase url-specific strengths.

HTTPS-only webhook

Webhook.tsxtsx
1const schema = {
2 webhookUrl: field.url('Webhook URL')
3 .required()
4 .format(/^https:\/\/.+$/, 'Use an HTTPS URL.'),
5}

OAuth callback with path check

OAuthCallback.tsxtsx
1const schema = {
2 redirectUri: field.url('Redirect URI')
3 .required()
4 .validate((value) =>
5 value.includes('/callback')
6 ? null
7 : 'URL must contain /callback path.',
8 ),
9}

Portfolio with hint

Portfolio.tsxtsx
1const schema = {
2 portfolio: field.url('Portfolio')
3 .optional()
4 .trim()
5 .hint('Full URL including https://'),
6}