-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
162 lines (98 loc) · 3.22 KB
/
README
File metadata and controls
162 lines (98 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
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
<https://github.com/iamalnewkirk/json-sql#readme> data structure
validation library based on the JSON-SQL json-schema
<https://json-schema.org> 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
}
});
# VALID
validate example #2
# given: synopsis
my $valid = $sql->validate({
insert => {
into => {
table => 'users'
},
default => 'true' # coerced booleans
}
});
# VALID
validate example #3
# given: synopsis
my $valid = $sql->validate({
insert => {
into => 'users',
values => [1, 2, 3]
}
});
# INVALID
AUTHOR
Al Newkirk, awncorp@cpan.org
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"
<https://github.com/iamalnewkirk/sql-validator/blob/master/LICENSE>.
PROJECT
Wiki <https://github.com/iamalnewkirk/sql-validator/wiki>
Project <https://github.com/iamalnewkirk/sql-validator>
Initiatives <https://github.com/iamalnewkirk/sql-validator/projects>
Milestones <https://github.com/iamalnewkirk/sql-validator/milestones>
Contributing
<https://github.com/iamalnewkirk/sql-validator/blob/master/CONTRIBUTE.md>
Issues <https://github.com/iamalnewkirk/sql-validator/issues>