Snippets

Brian Medley Validation and Filter example

Created by Brian Medley last modified
# Username [3-32 characters, characters "A-Za-z0-9_"]
# Password [8-16 characters, one uppercase, one digit]
# Verify Password [same as password]
# Phone Number [Optional Valid E164 on antartica]
# Favorite color [Optional one of "blue, red, green, yellow, black"]

$v->required("username")->trim->size(3, 32)->like(qr/^[A-Za-z0-9_]+$/);
$v->required("password")->trim->size(8, 16)->like(qr/[A-Z]/)->like(qr/[0-9]/);
$v->required("password_again")->trim->equal_to('password');
$v->optional("phone")->trim->fmt_e164->valid_e164->is_continent('antartica');
$v->optional("color")->trim->lc->in(qw(blue red green yellow black));

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.