Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/awncorp/sql-validator
Validate JSON-SQL Schemas
https://github.com/awncorp/sql-validator
json json-schema json-sql perl perl5 sql
Last synced: about 5 hours ago
JSON representation
Validate JSON-SQL Schemas
- Host: GitHub
- URL: https://github.com/awncorp/sql-validator
- Owner: awncorp
- License: other
- Created: 2020-07-25T00:59:12.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-10T04:42:08.000Z (about 4 years ago)
- Last Synced: 2024-06-21T19:00:13.254Z (5 months ago)
- Topics: json, json-schema, json-sql, perl, perl5, sql
- Language: Perl
- Homepage: https://metacpan.org/release/SQL-Validator
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: CHANGES
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
NAME
SQL::Validator - Validate JSON-SQL
ABSTRACT
Validate JSON-SQL Schemas
SYNOPSIS
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');DESCRIPTION
This package provides a json-sql
data structure
validation library based on the JSON-SQL json-schema
standard.ATTRIBUTES
This package has the following attributes:
schema
schema(Any)
This attribute is read-only, accepts (Any) values, and is optional.
validator
validator(InstanceOf["JSON::Validator"])
This attribute is read-only, accepts (InstanceOf["JSON::Validator"])
values, and is optional.version
version(Str)
This attribute is read-only, accepts (Str) values, and is optional.
METHODS
This package implements the following methods:
error
error() : InstanceOf["SQL::Validator::Error"]
The error method validates the JSON-SQL schema provided.
error example #1
# given: synopsis
$sql->validate({select => {}});
my $error = $sql->error;error example #2
# given: synopsis
$sql->validate({select => { from => { table => 'users' } } });
my $error = $sql->error;validate
validate(HashRef $schema) : Bool
The validate method validates the JSON-SQL schema provided.
validate example #1
# given: synopsis
my $valid = $sql->validate({
insert => {
into => {
table => 'users'
},
default => 1
}
});
# VALIDvalidate example #2
# given: synopsis
my $valid = $sql->validate({
insert => {
into => {
table => 'users'
},
default => 'true' # coerced booleans
}
});
# VALIDvalidate example #3
# given: synopsis
my $valid = $sql->validate({
insert => {
into => 'users',
values => [1, 2, 3]
}
});
# INVALIDAUTHOR
Al Newkirk, [email protected]
LICENSE
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"
.PROJECT
Wiki
Project
Initiatives
Milestones
Contributing
Issues