9
9
import com .relogiclabs .jschema .node .JObject ;
10
10
import com .relogiclabs .jschema .node .JString ;
11
11
import com .relogiclabs .jschema .node .JUndefined ;
12
- import com .relogiclabs .jschema .tree .RuntimeContext ;
13
12
14
13
import static com .relogiclabs .jschema .message .ErrorCode .ALEN01 ;
15
14
import static com .relogiclabs .jschema .message .ErrorCode .ALEN02 ;
28
27
import static com .relogiclabs .jschema .message .ErrorCode .SLEN05 ;
29
28
30
29
public abstract class CoreFunctions1 extends FunctionProvider {
31
- public CoreFunctions1 (RuntimeContext runtime ) {
32
- super (runtime );
33
- }
34
-
35
30
public boolean length (JString target , JInteger length ) {
36
31
var rLength = target .length ();
37
32
if (rLength != length .getValue ()) return fail (new JsonSchemaException (
38
- new ErrorDetail (SLEN01 , "Invalid length of string " , target ),
39
- new ExpectedDetail (caller , "a string of length " , length ),
40
- new ActualDetail (target , "found " , rLength , " which does not match" )));
33
+ new ErrorDetail (SLEN01 , "Invalid length of string " + target ),
34
+ new ExpectedDetail (caller , "a string of length " + length ),
35
+ new ActualDetail (target , "found " + rLength + " which does not match" )));
41
36
return true ;
42
37
}
43
38
44
39
public boolean length (JArray target , JInteger length ) {
45
40
var rLength = target .getElements ().size ();
46
41
if (rLength != length .getValue ()) return fail (new JsonSchemaException (
47
- new ErrorDetail (ALEN01 , "Invalid length of array " , target .getOutline ()),
48
- new ExpectedDetail (caller , "an array of length " , length ),
49
- new ActualDetail (target , "found " , rLength , " which does not match" )));
42
+ new ErrorDetail (ALEN01 , "Invalid length of array " + target .getOutline ()),
43
+ new ExpectedDetail (caller , "an array of length " + length ),
44
+ new ActualDetail (target , "found " + rLength + " which does not match" )));
50
45
return true ;
51
46
}
52
47
53
48
public boolean length (JObject target , JInteger length ) {
54
49
var rLength = target .getProperties ().size ();
55
50
if (rLength != length .getValue ()) return fail (new JsonSchemaException (
56
- new ErrorDetail (OLEN01 , "Invalid size or length of object " , target .getOutline ()),
57
- new ExpectedDetail (caller , "an object of length " , length ),
58
- new ActualDetail (target , "found " , rLength , " which does not match" )));
51
+ new ErrorDetail (OLEN01 , "Invalid size or length of object " + target .getOutline ()),
52
+ new ExpectedDetail (caller , "an object of length " + length ),
53
+ new ActualDetail (target , "found " + rLength + " which does not match" )));
59
54
return true ;
60
55
}
61
56
62
57
public boolean length (JString target , JInteger minimum , JInteger maximum ) {
63
58
var length = target .length ();
64
59
if (length < minimum .getValue ())
65
60
return fail (new JsonSchemaException (new ErrorDetail (SLEN02 ,
66
- "String " , target .getOutline (), " length is outside of range" ),
67
- new ExpectedDetail (caller , "length in range [" , minimum , ", " , maximum , "]" ),
68
- new ActualDetail (target , "found " , length , " that is less than " , minimum )));
61
+ "String " + target .getOutline () + " length is outside of range" ),
62
+ new ExpectedDetail (caller , "length in range [" + minimum + ", " + maximum + "]" ),
63
+ new ActualDetail (target , "found " + length + " that is less than " + minimum )));
69
64
if (length > maximum .getValue ())
70
65
return fail (new JsonSchemaException (new ErrorDetail (SLEN03 ,
71
- "String " , target .getOutline (), " length is outside of range" ),
72
- new ExpectedDetail (caller , "length in range [" , minimum , ", " , maximum , "]" ),
73
- new ActualDetail (target , "found " , length , " that is greater than " , maximum )));
66
+ "String " + target .getOutline () + " length is outside of range" ),
67
+ new ExpectedDetail (caller , "length in range [" + minimum + ", " + maximum + "]" ),
68
+ new ActualDetail (target , "found " + length + " that is greater than " + maximum )));
74
69
return true ;
75
70
}
76
71
77
72
public boolean length (JString target , JInteger minimum , JUndefined undefined ) {
78
73
var length = target .length ();
79
74
if (length < minimum .getValue ())
80
75
return fail (new JsonSchemaException (new ErrorDetail (SLEN04 ,
81
- "String " , target .getOutline (), " length is outside of range" ),
82
- new ExpectedDetail (caller , "length in range [" , minimum , ", " , undefined , "]" ),
83
- new ActualDetail (target , "found " , length , " that is less than " , minimum )));
76
+ "String " + target .getOutline () + " length is outside of range" ),
77
+ new ExpectedDetail (caller , "length in range [" + minimum + ", " + undefined + "]" ),
78
+ new ActualDetail (target , "found " + length + " that is less than " + minimum )));
84
79
return true ;
85
80
}
86
81
87
82
public boolean length (JString target , JUndefined undefined , JInteger maximum ) {
88
83
var length = target .length ();
89
84
if (length > maximum .getValue ())
90
85
return fail (new JsonSchemaException (new ErrorDetail (SLEN05 ,
91
- "String " , target .getOutline (), " length is outside of range" ),
92
- new ExpectedDetail (caller , "length in range [" , undefined , ", " , maximum , "]" ),
93
- new ActualDetail (target , "found " , length , " that is greater than " , maximum )));
86
+ "String " + target .getOutline () + " length is outside of range" ),
87
+ new ExpectedDetail (caller , "length in range [" + undefined + ", " + maximum + "]" ),
88
+ new ActualDetail (target , "found " + length + " that is greater than " + maximum )));
94
89
return true ;
95
90
}
96
91
97
92
public boolean length (JArray target , JInteger minimum , JInteger maximum ) {
98
93
var length = target .getElements ().size ();
99
94
if (length < minimum .getValue ())
100
95
return fail (new JsonSchemaException (new ErrorDetail (ALEN02 ,
101
- "Array " , target .getOutline (), " length is outside of range" ),
102
- new ExpectedDetail (caller , "length in range [" , minimum , ", " , maximum , "]" ),
103
- new ActualDetail (target , "found " , length , " that is less than " , minimum )));
96
+ "Array " + target .getOutline () + " length is outside of range" ),
97
+ new ExpectedDetail (caller , "length in range [" + minimum + ", " + maximum + "]" ),
98
+ new ActualDetail (target , "found " + length + " that is less than " + minimum )));
104
99
if (length > maximum .getValue ())
105
100
return fail (new JsonSchemaException (new ErrorDetail (ALEN03 ,
106
- "Array " , target .getOutline (), " length is outside of range" ),
107
- new ExpectedDetail (caller , "length in range [" , minimum , ", " , maximum , "]" ),
108
- new ActualDetail (target , "found " , length , " that is greater than " , maximum )));
101
+ "Array " + target .getOutline () + " length is outside of range" ),
102
+ new ExpectedDetail (caller , "length in range [" + minimum + ", " + maximum + "]" ),
103
+ new ActualDetail (target , "found " + length + " that is greater than " + maximum )));
109
104
return true ;
110
105
}
111
106
112
107
public boolean length (JArray target , JInteger minimum , JUndefined undefined ) {
113
108
var length = target .getElements ().size ();
114
109
if (length < minimum .getValue ())
115
110
return fail (new JsonSchemaException (new ErrorDetail (ALEN04 ,
116
- "Array " , target .getOutline (), " length is outside of range" ),
117
- new ExpectedDetail (caller , "length in range [" , minimum , ", " , undefined , "]" ),
118
- new ActualDetail (target , "found " , length , " that is less than " , minimum )));
111
+ "Array " + target .getOutline () + " length is outside of range" ),
112
+ new ExpectedDetail (caller , "length in range [" + minimum + ", " + undefined + "]" ),
113
+ new ActualDetail (target , "found " + length + " that is less than " + minimum )));
119
114
return true ;
120
115
}
121
116
122
117
public boolean length (JArray target , JUndefined undefined , JInteger maximum ) {
123
118
var length = target .getElements ().size ();
124
119
if (length > maximum .getValue ())
125
120
return fail (new JsonSchemaException (new ErrorDetail (ALEN05 ,
126
- "Array " , target .getOutline (), " length is outside of range" ),
127
- new ExpectedDetail (caller , "length in range [" , undefined , ", " , maximum , "]" ),
128
- new ActualDetail (target , "found " , length , " that is greater than " , maximum )));
121
+ "Array " + target .getOutline () + " length is outside of range" ),
122
+ new ExpectedDetail (caller , "length in range [" + undefined + ", " + maximum + "]" ),
123
+ new ActualDetail (target , "found " + length + " that is greater than " + maximum )));
129
124
return true ;
130
125
}
131
126
132
127
public boolean length (JObject target , JInteger minimum , JInteger maximum ) {
133
128
var length = target .getProperties ().size ();
134
129
if (length < minimum .getValue ())
135
130
return fail (new JsonSchemaException (new ErrorDetail (OLEN02 ,
136
- "Object " , target .getOutline (), " size or length is outside of range" ),
137
- new ExpectedDetail (caller , "length in range [" , minimum , ", " , maximum , "]" ),
138
- new ActualDetail (target , "found " , length , " that is less than " , minimum )));
131
+ "Object " + target .getOutline () + " size or length is outside of range" ),
132
+ new ExpectedDetail (caller , "length in range [" + minimum + ", " + maximum + "]" ),
133
+ new ActualDetail (target , "found " + length + " that is less than " + minimum )));
139
134
if (length > maximum .getValue ())
140
135
return fail (new JsonSchemaException (new ErrorDetail (OLEN03 ,
141
- "Object " , target .getOutline (), " size or length is outside of range" ),
142
- new ExpectedDetail (caller , "length in range [" , minimum , ", " , maximum , "]" ),
143
- new ActualDetail (target , "found " , length , " that is greater than " , maximum )));
136
+ "Object " + target .getOutline () + " size or length is outside of range" ),
137
+ new ExpectedDetail (caller , "length in range [" + minimum + ", " + maximum + "]" ),
138
+ new ActualDetail (target , "found " + length + " that is greater than " + maximum )));
144
139
return true ;
145
140
}
146
141
147
142
public boolean length (JObject target , JInteger minimum , JUndefined undefined ) {
148
143
var length = target .getProperties ().size ();
149
144
if (length < minimum .getValue ())
150
145
return fail (new JsonSchemaException (new ErrorDetail (OLEN04 ,
151
- "Object " , target .getOutline (), " size or length is outside of range" ),
152
- new ExpectedDetail (caller , "length in range [" , minimum , ", " , undefined , "]" ),
153
- new ActualDetail (target , "found " , length , " that is less than " , minimum )));
146
+ "Object " + target .getOutline () + " size or length is outside of range" ),
147
+ new ExpectedDetail (caller , "length in range [" + minimum + ", " + undefined + "]" ),
148
+ new ActualDetail (target , "found " + length + " that is less than " + minimum )));
154
149
return true ;
155
150
}
156
151
157
152
public boolean length (JObject target , JUndefined undefined , JInteger maximum ) {
158
153
var length = target .getProperties ().size ();
159
154
if (length > maximum .getValue ())
160
155
return fail (new JsonSchemaException (new ErrorDetail (OLEN05 ,
161
- "Object " , target .getOutline (), " size or length is outside of range" ),
162
- new ExpectedDetail (caller , "length in range [" , undefined , ", " , maximum , "]" ),
163
- new ActualDetail (target , "found " , length , " that is greater than " , maximum )));
156
+ "Object " + target .getOutline () + " size or length is outside of range" ),
157
+ new ExpectedDetail (caller , "length in range [" + undefined + ", " + maximum + "]" ),
158
+ new ActualDetail (target , "found " + length + " that is greater than " + maximum )));
164
159
return true ;
165
160
}
166
161
}
0 commit comments