99import com .relogiclabs .jschema .node .JObject ;
1010import com .relogiclabs .jschema .node .JString ;
1111import com .relogiclabs .jschema .node .JUndefined ;
12- import com .relogiclabs .jschema .tree .RuntimeContext ;
1312
1413import static com .relogiclabs .jschema .message .ErrorCode .ALEN01 ;
1514import static com .relogiclabs .jschema .message .ErrorCode .ALEN02 ;
2827import static com .relogiclabs .jschema .message .ErrorCode .SLEN05 ;
2928
3029public abstract class CoreFunctions1 extends FunctionProvider {
31- public CoreFunctions1 (RuntimeContext runtime ) {
32- super (runtime );
33- }
34-
3530 public boolean length (JString target , JInteger length ) {
3631 var rLength = target .length ();
3732 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" )));
4136 return true ;
4237 }
4338
4439 public boolean length (JArray target , JInteger length ) {
4540 var rLength = target .getElements ().size ();
4641 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" )));
5045 return true ;
5146 }
5247
5348 public boolean length (JObject target , JInteger length ) {
5449 var rLength = target .getProperties ().size ();
5550 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" )));
5954 return true ;
6055 }
6156
6257 public boolean length (JString target , JInteger minimum , JInteger maximum ) {
6358 var length = target .length ();
6459 if (length < minimum .getValue ())
6560 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 )));
6964 if (length > maximum .getValue ())
7065 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 )));
7469 return true ;
7570 }
7671
7772 public boolean length (JString target , JInteger minimum , JUndefined undefined ) {
7873 var length = target .length ();
7974 if (length < minimum .getValue ())
8075 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 )));
8479 return true ;
8580 }
8681
8782 public boolean length (JString target , JUndefined undefined , JInteger maximum ) {
8883 var length = target .length ();
8984 if (length > maximum .getValue ())
9085 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 )));
9489 return true ;
9590 }
9691
9792 public boolean length (JArray target , JInteger minimum , JInteger maximum ) {
9893 var length = target .getElements ().size ();
9994 if (length < minimum .getValue ())
10095 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 )));
10499 if (length > maximum .getValue ())
105100 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 )));
109104 return true ;
110105 }
111106
112107 public boolean length (JArray target , JInteger minimum , JUndefined undefined ) {
113108 var length = target .getElements ().size ();
114109 if (length < minimum .getValue ())
115110 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 )));
119114 return true ;
120115 }
121116
122117 public boolean length (JArray target , JUndefined undefined , JInteger maximum ) {
123118 var length = target .getElements ().size ();
124119 if (length > maximum .getValue ())
125120 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 )));
129124 return true ;
130125 }
131126
132127 public boolean length (JObject target , JInteger minimum , JInteger maximum ) {
133128 var length = target .getProperties ().size ();
134129 if (length < minimum .getValue ())
135130 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 )));
139134 if (length > maximum .getValue ())
140135 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 )));
144139 return true ;
145140 }
146141
147142 public boolean length (JObject target , JInteger minimum , JUndefined undefined ) {
148143 var length = target .getProperties ().size ();
149144 if (length < minimum .getValue ())
150145 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 )));
154149 return true ;
155150 }
156151
157152 public boolean length (JObject target , JUndefined undefined , JInteger maximum ) {
158153 var length = target .getProperties ().size ();
159154 if (length > maximum .getValue ())
160155 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 )));
164159 return true ;
165160 }
166161}
0 commit comments