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

NAME

Syccess::Validator::Code - A validator to check a value through a simple coderef

VERSION

version 0.104

SYNOPSIS

  Syccess->new(
    fields => [
      foo => [ code => sub { $_ > 3 ? () : ('You are WRONG!') } ],
      bar => [ code => {
        arg => sub { $_ > 5 ? () : (undef) },
        message => 'You have 5 seconds to comply.'
      } ],
    ],
  );

DESCRIPTION

This validator allows checking against a CodeRef. The CodeRef will be getting all parameters on @_ as Hash, and the specific parameter value for to check against will be in $_, so the coderef can decide which way he want to check.

The CodeRef should give back nothing (not even undef) if its a success. Else if should give back undef to release the error message given on "message" or the default error message 'Your value for %s is not valid.'. Alternative it can also give back a string which will be used as message for the error.

ATTRIBUTES

message

This contains the error message or the format for the error message generation. See "validator_message" in Syccess::Error.

SUPPORT

IRC

  Join irc.perl.org and msg Getty

Repository

  http://github.com/Getty/p5-syccess
  Pull request and additional contributors are welcome

Issue Tracker

  http://github.com/Getty/p5-syccess/issues

AUTHOR

Torsten Raudssus <torsten@raudss.us>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Torsten Raudssus.

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