Skip to content

Validation

phil/url-bundle

UrlOfType checks that a value — a text, a Url or a TypedUrl — is a web address of one of the accepted kinds. null and the empty text are valid; add NotBlank to require one.

#[UrlOfType([KnownUrlType::Facebook, KnownUrlType::Instagram])]
public ?string $social = null;

#[UrlOfType(RegistryUrlType::class)]
public ?string $registry = null;
OptionDefault
typesEvery international kind; see kinds.md
messageThis value is not a valid web address., code UrlOfType::INVALID_ERROR
typeMessageThis address is not one of the accepted kinds: {{ types }}., code UrlOfType::NOT_ACCEPTED_ERROR

A TypedUrl is checked by its kind: one of Website is refused by a constraint accepting only Facebook, even when the address is on Facebook.