GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Validation::Class::Simple::Streamer(3) User Contributed Perl Documentation Validation::Class::Simple::Streamer(3)

Validation::Class::Simple::Streamer - Simple Streaming Data Validation

version 7.900057

    use Validation::Class::Simple::Streamer;

    my $params = {
        credit_card   => '0000000000000000',
        email_address => 'root@localhost',

    };

    my $rules = Validation::Class::Simple::Streamer->new(params => $params);

    # the point here is expressiveness
    # directive methods auto-validate in boolean context !!!

    if (not $rules->check('credit_card')->creditcard(['visa', 'mastercard'])) {
        # credit card is invalid visa/mastercard
        warn $rules->errors_to_string;
    }

    if (not $rules->check('email_address')->min_length(3)->email) {
        # email address is invalid
        warn $rules->errors_to_string;
    }

    # prepare password for validation
    $rules->check('password');

    die "Password is not valid"
        unless $rules->min_symbols(1) && $rules->matches('password2');

    # are you of legal age?
    if ($rules->check('member_years_of_age')->between('18-75')) {
        # access to explicit content approved
    }

    # get all fields with errors
    my $fields = $rules->error_fields;

    # warn with errors if any
    warn $rules->errors_to_string unless $rules->validate;

Validation::Class::Simple::Streamer is a simple streaming validation module that makes data validation fun. Target parameters and attach matching fields and directives to them by chaining together methods which represent Validation::Class directives. This module is built around the powerful Validation::Class data validation framework via Validation::Class::Simple. This module is a sub-class of and derived from the Validation::Class::Simple class.

If you are new to Validation::Class, or would like more information on the underpinnings of this library and how it views and approaches data validation, please review Validation::Class::Whitepaper. Please review the "GUIDED-TOUR" in Validation::Class::Cookbook for a detailed step-by-step look into how Validation::Class works.

The check method specifies the parameter to be affected by directive methods if/when called.

    $self = $self->check('email_address'); # focus on email_address

    $self->required;        # apply the Required directive to email_address
    $self->min_symbols(1);  # apply the MinSymbols directive to email_address
    $self->min_length(5);   # apply the MinLength directive to email_address

The clear method resets the validation queue and declared fields but leaves the declared parameters in-tact, almost like the object state post-instantiation.

    $self->clear;

The messages method returns any registered errors as a concatenated string using the "errors_to_string" in Validation::Class::Prototype method and accepts the same parameters.

    print $self->messages;

The validate method uses the validator to perform data validation based on the series and sequence of commands issued previously. This method is called implicitly whenever the object is used in boolean context, e.g. in a conditional.

    $true = $self->validate;

Each instance of Validation::Class::Simple::Streamer is injected with a few proxy methods which are basically aliases to the corresponding prototype class methods, however it is possible to access the prototype directly using the proto/prototype methods.

    $self->class;

See "class" in Validation::Class::Prototype for full documentation.

    $self->clear_queue;

See "clear_queue" in Validation::Class::Prototype for full documentation.

    $self->error_count;

See "error_count" in Validation::Class::Prototype for full documentation.

    $self->error_fields;

See "error_fields" in Validation::Class::Prototype for full documentation.

    $self->errors;

See "errors" in Validation::Class::Prototype for full documentation.

    $self->errors_to_string;

See "errors_to_string" in Validation::Class::Prototype for full documentation.

    $self->get_errors;

See "get_errors" in Validation::Class::Prototype for full documentation.

    $self->get_fields;

See "get_fields" in Validation::Class::Prototype for full documentation.

    $self->get_hash;

See "get_hash" in Validation::Class::Prototype for full documentation.

    $self->get_params;

See "get_params" in Validation::Class::Prototype for full documentation.

    $self->get_values;

See "get_values" in Validation::Class::Prototype for full documentation.

    $self->fields;

See "fields" in Validation::Class::Prototype for full documentation.

    $self->filtering;

See "filtering" in Validation::Class::Prototype for full documentation.

    $self->ignore_failure;

See "ignore_failure" in Validation::Class::Prototype for full documentation.

    $self->ignore_unknown;

See "ignore_unknown" in Validation::Class::Prototype for full documentation.

    $self->is_valid;

See "is_valid" in Validation::Class::Prototype for full documentation.

    $self->param;

See "param" in Validation::Class::Prototype for full documentation.

    $self->params;

See "params" in Validation::Class::Prototype for full documentation.

    $self->plugin;

See "plugin" in Validation::Class::Prototype for full documentation.

    $self->queue;

See "queue" in Validation::Class::Prototype for full documentation.

    $self->report_failure;

See "report_failure" in Validation::Class::Prototype for full documentation.

    $self->report_unknown;

See "report_unknown" in Validation::Class::Prototype for full documentation.

    $self->reset_errors;

See "reset_errors" in Validation::Class::Prototype for full documentation.

    $self->reset_fields;

See "reset_fields" in Validation::Class::Prototype for full documentation.

    $self->reset_params;

See "reset_params" in Validation::Class::Prototype for full documentation.

    $self->set_errors;

See "set_errors" in Validation::Class::Prototype for full documentation.

    $self->set_fields;

See "set_fields" in Validation::Class::Prototype for full documentation.

    $self->set_params;

See "set_params" in Validation::Class::Prototype for full documentation.

    $self->set_method;

See "set_method" in Validation::Class::Prototype for full documentation.

    $self->stash;

See "stash" in Validation::Class::Prototype for full documentation.

    $self->validate;

See "validate" in Validation::Class::Prototype for full documentation.

    $self->validate_method;

See "validate_method" in Validation::Class::Prototype for full documentation.

    $self->validate_profile;

See "validate_profile" in Validation::Class::Prototype for full documentation.

Al Newkirk <anewkirk@ana.io>

This software is copyright (c) 2011 by Al Newkirk.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2015-10-21 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.