Steven Haryanto > Data-Sah-0.29 > Data::Sah::JS

Download:
Data-Sah-0.29.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.29   Source  

NAME ^

Data::Sah::JS - Some functions to use JavaScript Sah validator code from Perl

VERSION ^

This document describes version 0.29 of Data::Sah::JS (from Perl distribution Data-Sah), released on 2014-06-30.

SYNOPSIS ^

 use Data::Sah::JS qw(gen_validator);

 my $v = gen_validator(["int*", min=>1, max=>10]);

 # validate your data using the generated validator
 say "valid" if $v->(5);     # valid
 say "valid" if $v->(11);    # invalid
 say "valid" if $v->(undef); # invalid
 say "valid" if $v->("x");   # invalid

 # generate validator which reports error message string, in Indonesian
 my $v = gen_validator(["int*", min=>1, max=>10],
                       {return_type=>'str', lang=>'id_ID'});
 say $v->(5);  # ''
 say $v->(12); # 'Data tidak boleh lebih besar dari 10'
               # (in English: 'Data must not be larger than 10')

DESCRIPTION ^

FUNCTIONS ^

None exported by default.

gen_validator($schema, \%opts) => CODE (or STR)

Generate validator code for $schema. This is currently used for testing purposes only, as this will first generate JavaScript validator code, then generate a Perl coderef that will feed generated JavaScript validator code to a JavaScript engine (currently node.js) via command-line. Not exactly efficient.

Known options (unknown options will be passed to JS schema compiler):

ENVIRONMENT ^

LOG_SAH_VALIDATOR_CODE

SEE ALSO ^

Data::Sah, Data::Sah::Compiler::js.

HOMEPAGE ^

Please visit the project's homepage at https://metacpan.org/release/Data-Sah.

SOURCE ^

Source repository is at https://github.com/sharyanto/perl-Data-Sah.

BUGS ^

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Sah

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR ^

Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2014 by Steven Haryanto.

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

syntax highlighting: