The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Slovo::Validator - additional validator filters and checks

CHECKS

Slovo::Validator inherits all checks from Mojolicious::Validator and implements the following new ones.

is

A custom check -- some code reference which returns true on success, false otherwise.

  # in the action
  $v->required('id')->is(\&_writable_by, $c->stranici, $c->user);

  # in the same or parent controller
  sub _writable_by ($v, $id_name, $id_value, $m, $user) {
    return !!$m->find_where({$id_name => $id_value, %{$m->writable_by($user)}});
  }

  # or simply
  $v->required('sum')->is(sub($v, $name, $value) {
    $v->param('one') + $v->param('two') == $value
  });

can

An alias for "is".

FILTERS

Slovo::Validator inherits all filters from Mojolicious::Validator and implements the following new ones.

slugify

  $v->required('alias', 'slugify')->size(0, 255);

Generate URL slug for bytestream with "slugify" in Mojo::Util.

xml_escape

  $c->validation->optional(title => xml_escape => 'trim')->size(10, 255);

Uses "xml_escape" in Mojo::Util to escape unsafe characters. Returns the escaped string.

SEE ALSO

Mojolicious::Validator, "Form-validation" in Mojolicious::Guides::Rendering