Validation::Class::Directive::Options(3pm)

Validation::Class::Directive::Options3pm

Options directive for validation class field definitions

Usage

    use Validation::Class::Simple;
    my $rules = Validation::Class::Simple->new(
        fields => {
            user_role => {
                options => 'Client'
            }
        }
    );
    # set parameters to be validated
    $rules->params->add($parameters);
    # validate
    unless ($rules->validate) {
        # handle the failures
    }

Version

version 7.900059

Overview

Validation::Class::Directive::Options is a core validation class field directive that holds an enumerated list of values to be validated against the associated parameters.

•

alternative argument: an-array-of-user-defined-options

This directive can be passed a single value or an array of values:

    fields => {
        user_role => {
            options => ['Client', 'Employee', 'Administrator']
        }
    }
    # the following examples are useful for plugins (and other code)
    # that may want to otherwise identify option values
    fields => {
        user_role => {
            options => [
                '1|Client',
                '2|Employee',
                '3|Administrator'
            ]
        }
    }
    # please note:
    # declaring options as "keyed-options" will cause the validation of
    # the option's key and NOT the option's value
    fields => {
        user_role => {
            options => [
                [ 1 => 'Client' ],
                [ 2 => 'Employee' ],
                [ 3 => 'Administrator' ]
            ]
        }
    }

Releases

6 releases since Debian 8 (Jessie); the text changed 4 times.

  1. 8
  2. 9
  3. 10–11
  4. 12
  5. 13

Author

Al Newkirk <[email protected]>

From libvalidation-class-perl 7.900059-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.