respect-validation/docs/validators/VideoUrl.md
Henrique Moody d2198dfd01
Replace isValid() calls with assert()
There's more value on showing how `assert()` displays the validation
messages than simply showing if `isValid()` returns `true` or `false`.

However, that increases the chances of having outdated documentation, so
I created a doc linter that updates the Markdown files with the
correct message.
2026-01-13 23:37:06 -07:00

3.1 KiB

VideoUrl

  • VideoUrl()
  • VideoUrl(string $service)

Validates if the input is a video URL value.

v::videoUrl()->assert('https://player.vimeo.com/video/71787467');
// Validation passes successfully

v::videoUrl()->assert('https://vimeo.com/71787467');
// Validation passes successfully

v::videoUrl()->assert('https://www.youtube.com/embed/netHLn9TScY');
// Validation passes successfully

v::videoUrl()->assert('https://www.youtube.com/watch?v=netHLn9TScY');
// Validation passes successfully

v::videoUrl()->assert('https://youtu.be/netHLn9TScY');
// Validation passes successfully

v::videoUrl()->assert('https://www.twitch.tv/videos/320689092');
// Validation passes successfully

v::videoUrl()->assert('https://clips.twitch.tv/BitterLazyMangetoutHumbleLife');
// Validation passes successfully

v::videoUrl('youtube')->assert('https://www.youtube.com/watch?v=netHLn9TScY');
// Validation passes successfully

v::videoUrl('vimeo')->assert('https://vimeo.com/71787467');
// Validation passes successfully

v::videoUrl('twitch')->assert('https://www.twitch.tv/videos/320689092');
// Validation passes successfully

v::videoUrl('twitch')->assert('https://clips.twitch.tv/BitterLazyMangetoutHumbleLife');
// Validation passes successfully

v::videoUrl()->assert('https://youtube.com');
// → "https://youtube.com" must be a valid video URL

v::videoUrl('youtube')->assert('https://vimeo.com/71787467');
// → "https://vimeo.com/71787467" must be a valid youtube video URL

v::videoUrl('twitch')->assert('https://clips.twitch.tv/videos/90210');
// → "https://clips.twitch.tv/videos/90210" must be a valid twitch video URL

v::videoUrl('twitch')->assert('https://twitch.tv/TakeTeaAndNoTea');
// → "https://twitch.tv/TakeTeaAndNoTea" must be a valid twitch video URL

The services accepted are:

  • YouTube
  • Vimeo
  • Twitch (videos and clips)

The $service value is not case-sensitive.

Message template for this validator includes {{service}}.

Templates

VideoUrl::TEMPLATE_STANDARD

Mode Template
default {{subject}} must be a valid video URL
inverted {{subject}} must not be a valid video URL

VideoUrl::TEMPLATE_SERVICE

Mode Template
default {{subject}} must be a valid {{service|raw}} video URL
inverted {{subject}} must not be a valid {{service|raw}} video URL

Template placeholders

Placeholder Description
subject The validated input or the custom validator name (if specified).
service

Categorization

  • Internet

Changelog

Version Description
1.0.0 Created

See also: