SQL::Validator - Validate JSON-SQL
Validate JSON-SQL Schemas
use SQL::Validator; my $sql = SQL::Validator->new; # my $valid = $sql->validate({ # insert => { # into => { # table => 'users' # }, # default => 1 # } # }); # i.e. represents (INSERT INTO "users" DEFAULT VALUES) # die $sql->error if !$valid; # $sql->error->report('insert');
This package provides a json-sql data structure validation library based on the JSON-SQL json-schema standard.
This package has the following attributes:
schema(Any)
This attribute is read-only, accepts (Any) values, and is optional.
(Any)
validator(InstanceOf["JSON::Validator"])
This attribute is read-only, accepts (InstanceOf["JSON::Validator"]) values, and is optional.
(InstanceOf["JSON::Validator"])
version(Str)
This attribute is read-only, accepts (Str) values, and is optional.
(Str)
This package implements the following methods:
error() : InstanceOf["SQL::Validator::Error"]
The error method validates the JSON-SQL schema provided.
# given: synopsis $sql->validate({select => {}}); my $error = $sql->error;
# given: synopsis $sql->validate({select => { from => { table => 'users' } } }); my $error = $sql->error;
validate(HashRef $schema) : Bool
The validate method validates the JSON-SQL schema provided.
# given: synopsis my $valid = $sql->validate({ insert => { into => { table => 'users' }, default => 1 } }); # VALID
# given: synopsis my $valid = $sql->validate({ insert => { into => { table => 'users' }, default => 'true' # coerced booleans } }); # VALID
# given: synopsis my $valid = $sql->validate({ insert => { into => 'users', values => [1, 2, 3] } }); # INVALID
Al Newkirk, awncorp@cpan.org
awncorp@cpan.org
Copyright (C) 2011-2019, Al Newkirk, et al.
This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".
Wiki
Project
Initiatives
Milestones
Contributing
Issues
To install SQL::Validator, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SQL::Validator
CPAN shell
perl -MCPAN -e shell install SQL::Validator
For more information on module installation, please visit the detailed CPAN module installation guide.