validator

input

Quick Reference

v :: $bool
Field v is a boolean
v != true
Field v is a boolean which is false
D *= "bc"
D is a string which contains the substring bc
"num" < -100
num is an int which is less than negative 100
u >= uint(100)
u is an unsigned int which is greater than or equal to a 100
F > double(0.5)
F is a floating point number which is greater than a half.
"F g\\" :: $bool
F g\ is a boolean. Notice the escaped backslash. Quotes are useful for spaces and other escapable characters.
`F g\` :: $bool
F g\ is a boolean. Notice the backslash is included in the string. Backticks are useful for literal and even multiline unescaped strings.
B == []byte{0xfe,'a',255}
B is an array of bytes which equals {254,97,255}. note: json has no bytes type.
a ^= "abc"
... starts with abc
a $= "xyz"
... ends with xyz
a ~= "^abc.*xyz$"
... matches the regular expression, which means it starts with abc and ends with xyz
D -> contains($string, "bc")
D is a string which contains the substring bc
L -> gt(length($[]byte), 0)
L is an array of bytes which has a length greater than zero
N -> and(ge($int, 10), lt($int, 20))
N is an int which is greater than or equal to 10 and less than 20
*
The structure contains zero or more of anything
A: *
The structure contains exactly one field. That field is named A. It may have any value.
A: b == "c"
The structure contains one field named A, which contains one field named b, which equals c
[A:*, B:*]
Validates a structure that contains exactly two ordered fields, A followed by B. Each of these fields can contain anything.
{A:*; B:*}
Validates a structure that contains exactly two fields, A and B, but in any order.
C [A:*, B:*]
... one field C which contains two fields, A followed by B ...
C [(A:*)?, B:*]
C contains an optional field A followed by a required field B
D [0 == "a", 1 == "b"]
D contains an array where the zeroth element is a and the element at index one is b
E [0 == "b", *]
E contains an array which starts with a string b and is followed by zero or more elements
F [(_ == "a")*, _ == "b"]
F contains an array or a structure where the first elements all have value a and the final element has value b
(A:* | B:* | C:*)
... one field: A, B or C. The parentheses are not for arbitrary grouping, but are required for grouping of the same operator, for example | or &.
(C:* & D:*)
Well this is impossible. You cannot have exactly one field where the field name is equal to C and equal to D
((C:* | D:*) & (D:* | E:* | F:*))
You can have nested expressions. This will validate a structure with exactly one field named D.
_:*
one field, which has any name and contains anything
(A | B):*
one field named A or B
!(A):*
one field named anything except A
((A | B):* & (A | C):*)
one field named A
(A:*)*
zero or more fields named A, which each contains anything
!(A:*)
any structure that does have just one field named A
A: @myref
#myref = b=="c"
The structure contains one field named A, which contains one field named b, which equals c.
#main = A: (@main | b=="c")
one field A containing one field A ... where one eventually contains a field b which equals c
.A:*
equivalent to [*, A:*, *]. A structure which contains a field A. There can be many other fields around A.
.A.b == "c"
equivalent to [*, A:[*, b==c, *], *]. A structure which contains a field A, which contains a field b which is equal to c
.B._ == "c"
equivalent to [*, B:[*, _==c, *], *]. A structure which contains a field B, which contains a field or an array value which is equal to c
Powered By: gopherjs github codemirror gocc gogoprotobuf golang