Data::Rx - perl implementation of Rx schema system
version 0.004
my $rx = Data::Rx->new; my $success = { type => '//rec', required => { location => '//str', status => { type => '//int', value => 201 }, }, optional => { comments => { type => '//arr', contents => '//str', }, }, }; my $schema = $rx->make_schema($success); my $reply = $json->decode( $agent->get($http_request) ); die "invalid reply" unless $schema->check($reply);
http://rjbs.manxome.org/rx
my $rx = Data::Rx->new(\%arg);
This returns a new Data::Rx object.
Valid arguments are:
prefix - optional; a hashref of prefix strings and values for type shorthand type_plugins - optional; an arrayref of type plugins
The prefix hashref should look something like this:
{ 'pobox' => 'tag:pobox.com,1995:rx/core/', 'skynet' => 'tag:skynet.mil,1997-08-29:types/rx/', }
my $schema = $rx->make_schema($schema);
This returns a new schema checker (something with a check method) for the given Rx input.
check
$rx->register_type_plugin($plugin);
Given a type plugin, this registers the plugin with the Data::Rx object. Plugins must have a type_uri method and a new_checker method.
type_uri
new_checker
This method returns a list of the plugins for the core Rx types.
Ricardo SIGNES <rjbs@cpan.org>
This software is copyright (c) 2008 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under the same terms as perl itself.
To install Data::Rx, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Rx
CPAN shell
perl -MCPAN -e shell install Data::Rx
For more information on module installation, please visit the detailed CPAN module installation guide.