Class JsSpecs
JSON specifications are essential for parsing and validating JSON data in applications, ensuring that the data adheres to predefined rules before processing or storing it.
This class simplifies the creation of these specifications for various JSON data types, including numbers, strings, arrays, objects, and more.
It provides factory methods for creating specifications for different JSON types, including numbers, strings, arrays, and objects. Additionally, custom validation predicates can be specified to enforce specific constraints on JSON data.
JSON specifications created with this class are immutable and can be reused for validating multiple JSON data instances.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic JsSpec
any()
spec that is conformed by any valuestatic JsSpec
Returns a specification that accepts any JSON value for which the given predicate evaluates to true.static JsArraySpec
array()
non-nullable json arraystatic JsArraySpec
Returns a specification for a non-nullable array, where each element of the array satisfies the given predicate.static JsArraySpec
non-nullable array of integral numbersstatic JsArraySpec
arrayOfBigInt
(Predicate<BigInteger> predicate) Returns a specification for a non-nullable array of integral numbers, where each element of the array satisfies the given predicate.static JsArraySpec
arrayOfBigInt
(Predicate<BigInteger> predicate, ArraySchema arraySchema) Returns a specification for a non-nullable array of integral numbers, where each element of the array satisfies the given predicate.static JsArraySpec
arrayOfBigInt
(ArraySchema arraySchema) non-nullable array of big integer numbers.static JsArraySpec
arrayOfBigInt
(BigIntSchema schema) non-nullable array of big integer numbers.static JsArraySpec
arrayOfBigInt
(BigIntSchema schema, ArraySchema arraySchema) non-nullable array of big integer numbers.static JsArraySpec
arrayOfBigIntSuchThat
(Predicate<JsArray> predicate) Returns a specification for a non-nullable array of integral numbers, where each element of the array satisfies the given predicate.static JsArraySpec
non-nullable array of booleansstatic JsArraySpec
arrayOfBool
(ArraySchema schema) Returns a specification for an array of booleans with a specified minimum and maximum length.static JsArraySpec
arrayOfBoolSuchThat
(Predicate<JsArray> predicate) Returns a specification for a non-nullable array of booleans that satisfies the given predicate.static JsArraySpec
non-nullable array of decimal numbersstatic JsArraySpec
arrayOfDec
(Predicate<BigDecimal> predicate) Returns a specification for a non-nullable array of decimal numbers, where each element of the array satisfies the given predicate.static JsArraySpec
arrayOfDec
(Predicate<BigDecimal> predicate, ArraySchema arraySchema) Returns a specification for a non-nullable array of decimal numbers, where each element of the array satisfies the given predicate.static JsArraySpec
arrayOfDec
(ArraySchema arraySchema) non-nullable array of big decimal numbers.static JsArraySpec
arrayOfDec
(DecimalSchema schema) non-nullable array of big decimal numbers.static JsArraySpec
arrayOfDec
(DecimalSchema schema, ArraySchema arraySchema) static JsArraySpec
arrayOfDecSuchThat
(Predicate<JsArray> predicate) Returns a specification for a non-nullable array of decimal numbers, where each element of the array satisfies the given predicate.static JsArraySpec
non-nullable array of double numbersstatic JsArraySpec
arrayOfDouble
(DoublePredicate predicate, ArraySchema arraySchema) non-nullable array of decimal numbers.static JsArraySpec
arrayOfDouble
(Predicate<Double> predicate) Returns a specification for a non-nullable array of decimal numbers, where each element of the array satisfies the given predicate.static JsArraySpec
arrayOfDouble
(ArraySchema arraySchema) non-nullable array of double numbers.static JsArraySpec
arrayOfDouble
(DoubleSchema schema) non-nullable array of double numbers.static JsArraySpec
arrayOfDouble
(DoubleSchema schema, ArraySchema arraySchema) non-nullable array of double numbers.static JsArraySpec
arrayOfDoubleSuchThat
(Predicate<JsArray> predicate) Returns a specification for a non-nullable array of double that satisfies the given predicate.static JsArraySpec
non-nullable array of integer numbersstatic JsArraySpec
arrayOfInt
(IntPredicate predicate) Returns a specification for a non-nullable array of integer numbers, where each element of the array satisfies the given predicate.static JsArraySpec
arrayOfInt
(IntPredicate predicate, ArraySchema arraySchema) Returns a specification for a non-nullable array of integer numbers, where each element of the array satisfies the given predicate.static JsArraySpec
arrayOfInt
(ArraySchema schema) non-nullable array of integer numbers.static JsArraySpec
arrayOfInt
(IntegerSchema schema) non-nullable array of integer numbers.static JsArraySpec
arrayOfInt
(IntegerSchema schema, ArraySchema arraySchema) non-nullable array of integer numbers.static JsArraySpec
arrayOfIntSuchThat
(Predicate<JsArray> predicate) Returns a specification for a non-nullable array of integer numbers, where each element of the array satisfies the given predicate.static JsArraySpec
non-nullable array of long numbersstatic JsArraySpec
arrayOfLong
(LongPredicate predicate) Returns a specification for a non-nullable array of long numbers, where each element of the array satisfies the given predicate.static JsArraySpec
arrayOfLong
(LongPredicate predicate, ArraySchema schema) Returns a specification for a non-nullable array of long numbers, where each element of the array satisfies the given predicate.static JsArraySpec
arrayOfLong
(ArraySchema schema) Returns a specification for an array of long numbers with a specified minimum and maximum length.static JsArraySpec
arrayOfLong
(LongSchema schema) non-nullable array of long numbers.static JsArraySpec
arrayOfLong
(LongSchema schema, ArraySchema arraySchema) non-nullable array of long numbers.static JsArraySpec
arrayOfLongSuchThat
(Predicate<JsArray> predicate) Returns a specification for a non-nullable array of long numbers that satisfies the given predicate.static JsArraySpec
non-nullable array of objectsstatic JsArraySpec
arrayOfObj
(Predicate<JsObj> predicate) Returns a specification for a non-nullable array of objects, where each element of the array satisfies the given predicate.static JsArraySpec
arrayOfObj
(Predicate<JsObj> predicate, ArraySchema arraySchema) Returns a specification for a non-nullable array of objects, where each element of the array satisfies the given predicate.static JsArraySpec
arrayOfObj
(ArraySchema arraySchema) non-nullable array of objects.static JsArraySpec
arrayOfObjSuchThat
(Predicate<JsArray> predicate) Returns a specification for a non-nullable array of objects that satisfies the given predicate.static JsArraySpec
arrayOfSpec
(JsSpec spec) Returns a specification that validates that the JSON is an array, and the value of each element is a value that conforms the given spec.static JsArraySpec
arrayOfSpec
(JsSpec spec, ArraySchema arraySchema) Returns a specification that validates that the JSON is an array, and the value of each element is a value that conforms the given spec.static JsArraySpec
non-nullable array of stringsstatic JsArraySpec
arrayOfStr
(Predicate<String> predicate) Returns a specification for a non-nullable array of strings, where each element of the array satisfies the given predicate.static JsArraySpec
arrayOfStr
(Predicate<String> predicate, ArraySchema arraySchema) Returns a specification for a non-nullable array of strings, where each element of the array satisfies the given predicate.static JsArraySpec
arrayOfStr
(ArraySchema arraySchema) Returns a specification for an array of strings with a specified minimum and maximum length.static JsArraySpec
arrayOfStr
(StrSchema schema) Returns a specification for a non-nullable array of strings, where each element of the array satisfies the given schema.static JsArraySpec
arrayOfStr
(StrSchema elemSchema, ArraySchema arraySchema) Returns a specification for an array of strings with a specified minimum and maximum length, and each element conforming to the given element schema.static JsArraySpec
arrayOfStrSuchThat
(Predicate<JsArray> predicate) Returns a specification for a non-nullable array of strings that satisfies the given predicate.static JsArraySpec
arraySuchThat
(Predicate<JsArray> predicate) Returns a specification for a non-nullable array that satisfies the given predicate.static JsSpec
non-nullable big integer numberstatic JsSpec
bigInteger
(Predicate<BigInteger> predicate) Returns a specification for a non-nullable big integer number that satisfies the given predicate.static JsSpec
bigInteger
(BigIntSchema schema) Returns a specification for a non-nullable big integer number that satisfies the given schema.static JsSpec
binary()
non-nullable binarystatic JsSpec
Returns a specification for a non-nullable binary data that satisfies the given predicate.static JsSpec
bool()
non-nullable booleanstatic JsSpec
static JsSpec
Returns a required and non-nullable specification that specifies a constant value.static JsSpec
decimal()
non-nullable decimal numberstatic JsSpec
decimal
(Predicate<BigDecimal> predicate) Returns a specification for a non-nullable decimal number that satisfies the given predicate.static JsSpec
decimal
(DecimalSchema schema) Returns a specification for a non-nullable decimal number that satisfies the given schemastatic JsSpec
non-nullable double numberstatic JsSpec
doubleNumber
(DoublePredicate predicate) Returns a specification for a non-nullable double number that satisfies the given predicate.static JsSpec
doubleNumber
(DoubleSchema schema) non-nullable double number.static JsSpec
fixedBinary
(int length) non-nullable fixed-length binarystatic JsSpec
instant()
non-nullable instant specstatic JsSpec
Returns a specification for a non-nullable instant that satisfies the given predicate.static JsSpec
instant
(InstantSchema schema) Returns a specification for a non-nullable JSON instant that satisfies the given schema.static JsSpec
integer()
non-nullable integer numberstatic JsSpec
integer
(IntPredicate predicate) Returns a specification for a non-nullable integer number that satisfies the given predicate.static JsSpec
integer
(IntegerSchema schema) non-nullable integer number Each element of the array must satisfy the given schema.static JsSpec
non-nullable long numberstatic JsSpec
longInteger
(LongPredicate predicate) Returns a specification for a non-nullable long number that satisfies the given predicate.static JsSpec
longInteger
(LongSchema schema) Returns a specification for a non-nullable long number that satisfies the given schema.static JsSpec
Returns a specification that validates that the JSON is an object, and the value of each key is a big integer.static JsSpec
mapOfBigInteger
(BigIntSchema schema) Returns a specification that validates that the JSON is an object, and the value of each key is a big integer that satisfies the given schema.static JsSpec
Returns a specification that validates that the JSON is an object, and the value of each key is a binary.static JsSpec
Returns a specification that validates that the JSON is an object, and the value of each key is a boolean.static JsSpec
Returns a specification that validates that the JSON is an object, and the value of each key is a decimal number.static JsSpec
mapOfDecimal
(DecimalSchema decimalSchema) Returns a specification that validates that the JSON is an object, and the value of each key is a decimal number that satisfies the given schema.static JsSpec
Returns a specification that validates that the JSON is an object, and the value of each key is a double.static JsSpec
mapOfDouble
(DoubleSchema doubleSchema) Returns a specification that validates that the JSON is an object, and the value of each key is a double that satisfies the given schema.static JsSpec
Returns a specification that validates that the JSON is an object, and the value of each key is an instant.static JsSpec
mapOfInstant
(InstantSchema instantSchema) Returns a specification that validates that the JSON is an object, and the value of each key is an instant that satifies the given schema.static JsSpec
Returns a specification that validates that the JSON is an object, and the value of each key is an integer.static JsSpec
Returns a specification that validates that the JSON is an object, and the value of each key is a long number.static JsSpec
Returns a specification that validates that the JSON is an object, and the value of each key is an object.static JsSpec
Returns a specification that validates that the JSON is an object, and the value of each key is a value that conforms the given spec.static JsSpec
mapOfStr()
Returns a specification that validates that the JSON is an object, and the value of each key is a string.static JsSpec
static JsSpec
obj()
non-nullable json objectstatic JsSpec
Returns a specification for a non-nullable object that satisfies the given predicate.static JsSpec
ofNamedSpec
(String name) Returns a named spec from the cache based on the provided name.static JsSpec
ofNamedSpec
(String name, JsSpec spec) Creates and caches a named spec.static JsSpec
Returns a specification that validates if a JSON value is one of the given possible specifications.static JsSpec
Returns a specification that validates if a JSON value is one of the given possible specifications.static JsSpec
oneStringOf
(String elem, String... others) Returns a specification that validates if a JSON value is one of the given possible symbols.static JsSpec
oneStringOf
(List<String> cons) Returns a specification that validates if a JSON value is one of the given possible symbols.Returns a specification that validates if a JSON value is one of the given possible values.oneValOf
(O elem, O... others) Returns a specification that validates if a JSON value is one of the given possible values.static JsSpec
str()
non-nullable stringstatic JsSpec
Returns a specification for a non-nullable string, where the string satisfies the given predicate.static JsSpec
non-nullable string Each element of the array must satisfy the given schema.static JsArraySpec
Returns a tuple specification where each nth element of the tuple is specified by the nth given spec.
-
Method Details
-
arrayOfDec
non-nullable array of decimal numbers- Returns:
- a spec
-
arrayOfBigInt
non-nullable array of integral numbers- Returns:
- a spec
-
arrayOfDouble
non-nullable array of double numbers- Returns:
- a spec
-
arrayOfObj
non-nullable array of objects- Returns:
- a spec
-
arrayOfBool
non-nullable array of booleans- Returns:
- a spec
-
instant
non-nullable instant spec- Returns:
- a spec
-
arrayOfLong
non-nullable array of long numbers- Returns:
- a spec
-
arrayOfLong
non-nullable array of long numbers. Each element of the array must satisfy the given schema.- Returns:
- a spec
-
arrayOfLong
non-nullable array of long numbers. Each element of the array must satisfy the given schema. The array must satisfy the given array schema (min and max item, unique elements etc).- Parameters:
schema
- the schema that each element of the array must satisfyarraySchema
- the schema that the array must satisfy- Returns:
- a spec
-
arrayOfInt
non-nullable array of integer numbers- Returns:
- a spec
-
arrayOfStr
non-nullable array of strings- Returns:
- a spec
-
binary
non-nullable binary- Returns:
- a spec
- See Also:
-
fixedBinary
non-nullable fixed-length binary- Parameters:
length
- the length of the binary- Returns:
- a spec
- See Also:
-
bigInteger
non-nullable big integer number- Returns:
- a spec
-
longInteger
non-nullable long number- Returns:
- a spec
-
doubleNumber
non-nullable double number- Returns:
- a spec
-
doubleNumber
non-nullable double number. Each element of the array must satisfy the given schema.- Parameters:
schema
- the schema that each element of the array must satisfy- Returns:
- a spec
-
bool
non-nullable boolean- Returns:
- a spec
-
decimal
non-nullable decimal number- Returns:
- a spec
-
integer
non-nullable integer number- Returns:
- a spec
-
integer
non-nullable integer number Each element of the array must satisfy the given schema.- Parameters:
schema
- the schema that each element of the array must satisfy- Returns:
- a spec
-
obj
non-nullable json object- Returns:
- a spec
-
array
non-nullable json array- Returns:
- a spec
-
any
spec that is conformed by any value- Returns:
- a spec
-
str
non-nullable string- Returns:
- a spec
-
str
non-nullable string Each element of the array must satisfy the given schema.- Parameters:
schema
- the schema that each element of the array must satisfy- Returns:
- a spec
-
arrayOfInt
non-nullable array of integer numbers. The array must satisfy the given schema (min and max item, unique elements etc).- Parameters:
schema
- the schema that the array must satisfy- Returns:
- a spec
-
arrayOfInt
non-nullable array of integer numbers. Each element of the array must satisfy the given schema.- Parameters:
schema
- the schema that each element of the array must satisfy- Returns:
- a spec
-
arrayOfInt
non-nullable array of integer numbers. Each element of the array must satisfy the given schema. The array must satisfy the given schema (min and max item, unique elements etc).- Parameters:
schema
- the schema that each element of the array must satisfyarraySchema
- the schema that the array must satisfy- Returns:
- a spec
-
arrayOfDouble
non-nullable array of double numbers. The array must satisfy the given schema (min and max item, unique elements etc).- Parameters:
arraySchema
- the schema that the array must satisfy- Returns:
- a spec
-
arrayOfDouble
non-nullable array of double numbers. Each element of the array must satisfy the given schema.- Parameters:
schema
- the schema that each element of the array must satisfy- Returns:
- a spec
-
arrayOfDouble
non-nullable array of double numbers. Each element of the array must satisfy the given schema. The array must satisfy the given schema (min and max item, unique elements etc).- Parameters:
schema
- the schema that each element of the array must satisfyarraySchema
- the schema that the array must satisfy- Returns:
- a spec
-
arrayOfDouble
non-nullable array of decimal numbers. Each element of the array must satisfy the given predicate. The array must satisfy the given schema (min and max item, unique elements etc).- Parameters:
predicate
- The predicate that each number in the array must satisfy.arraySchema
- the schema that the array must satisfy- Returns:
- a spec
-
arrayOfBigInt
non-nullable array of big integer numbers. The array must satisfy the given schema (min and max item, unique elements etc).- Parameters:
arraySchema
- the schema that the array must satisfy- Returns:
- a spec
-
arrayOfBigInt
non-nullable array of big integer numbers. Each element of the array must satisfy the given schema.- Parameters:
schema
- the schema that each element of the array must satisfy- Returns:
- a spec
-
arrayOfBigInt
non-nullable array of big integer numbers. Each element of the array must satisfy the given schema. The array must satisfy the given schema (min and max item, unique elements etc).- Parameters:
schema
- the schema that each element of the array must satisfyarraySchema
- the schema that the array must satisfy- Returns:
- a spec
-
arrayOfObj
non-nullable array of objects. The array must satisfy the given schema (min and max item, unique elements etc).- Parameters:
arraySchema
- the schema that the array must satisfy- Returns:
- a spec
-
arrayOfDec
non-nullable array of big decimal numbers. The array must satisfy the given schema (min and max item, unique elements etc).- Parameters:
arraySchema
- the schema that the array must satisfy- Returns:
- a spec
-
arrayOfDec
non-nullable array of big decimal numbers. Each element of the array must satisfy the given schema.- Parameters:
schema
- the schema that each element of the array must satisfy- Returns:
- a spec
-
arrayOfDec
-
arrayOfBool
Returns a specification for an array of booleans with a specified minimum and maximum length.- Parameters:
schema
- The schema defining constraints for the array.- Returns:
- A specification for an array of booleans with the specified length constraints.
-
arrayOfStr
Returns a specification for an array of strings with a specified minimum and maximum length.- Parameters:
arraySchema
- The schema defining constraints for the array.- Returns:
- A specification for an array of strings with the specified length constraints.
-
arrayOfStr
Returns a specification for an array of strings with a specified minimum and maximum length, and each element conforming to the given element schema.- Parameters:
elemSchema
- The schema defining constraints for each element in the array.arraySchema
- The schema defining constraints for the array.- Returns:
- A specification for an array of strings with the specified length constraints and element schema.
-
arrayOfLong
Returns a specification for an array of long numbers with a specified minimum and maximum length.- Parameters:
schema
- The schema defining constraints for the array.- Returns:
- A specification for an array of long numbers with the specified length constraints.
-
cons
Returns a required and non-nullable specification that specifies a constant value.- Parameters:
value
- The constant value.- Returns:
- A specification that enforces the provided constant value.
-
cons
-
str
Returns a specification for a non-nullable string, where the string satisfies the given predicate.- Parameters:
predicate
- The predicate that the string must satisfy.- Returns:
- A specification for strings based on the specified predicate.
-
arrayOfIntSuchThat
Returns a specification for a non-nullable array of integer numbers, where each element of the array satisfies the given predicate.- Parameters:
predicate
- The predicate that the entire array must satisfy.- Returns:
- An array specification for integer numbers based on the specified predicate.
-
arrayOfDec
Returns a specification for a non-nullable array of decimal numbers, where each element of the array satisfies the given predicate.- Parameters:
predicate
- The predicate that each decimal number in the array must satisfy.- Returns:
- An array specification for decimal numbers based on the specified predicate.
-
arrayOfDouble
Returns a specification for a non-nullable array of decimal numbers, where each element of the array satisfies the given predicate.- Parameters:
predicate
- The predicate that each decimal number in the array must satisfy.- Returns:
- An array specification for decimal numbers based on the specified predicate.
-
arrayOfDec
Returns a specification for a non-nullable array of decimal numbers, where each element of the array satisfies the given predicate. The array must have a size within the specified range.- Parameters:
predicate
- The predicate that each decimal number in the array must satisfy.arraySchema
- The schema defining constraints for the array.- Returns:
- An array specification for decimal numbers based on the specified predicate and size range.
-
arrayOfDecSuchThat
Returns a specification for a non-nullable array of decimal numbers, where each element of the array satisfies the given predicate.- Parameters:
predicate
- The predicate that each decimal number in the array must satisfy.- Returns:
- An array specification for decimal numbers based on the specified predicate.
-
arrayOfBigInt
Returns a specification for a non-nullable array of integral numbers, where each element of the array satisfies the given predicate.- Parameters:
predicate
- The predicate that each integral number in the array must satisfy.- Returns:
- An array specification for integral numbers based on the specified predicate.
-
arrayOfBigInt
Returns a specification for a non-nullable array of integral numbers, where each element of the array satisfies the given predicate. The array must have a minimum and maximum size as specified by the parameters.- Parameters:
predicate
- The predicate that each integral number in the array must satisfy.arraySchema
- The schema defining constraints for the array.- Returns:
- An array specification for integral numbers based on the specified predicate and size constraints.
-
arrayOfBigIntSuchThat
Returns a specification for a non-nullable array of integral numbers, where each element of the array satisfies the given predicate.- Parameters:
predicate
- The predicate that each integral number in the array must satisfy.- Returns:
- An array specification for integral numbers based on the specified predicate.
-
arrayOfObj
Returns a specification for a non-nullable array of objects, where each element of the array satisfies the given predicate.- Parameters:
predicate
- The predicate that each object in the array must satisfy.- Returns:
- An array specification for objects based on the specified predicate.
-
arrayOfObj
Returns a specification for a non-nullable array of objects, where each element of the array satisfies the given predicate.- Parameters:
predicate
- The predicate that each object in the array must satisfy.arraySchema
- The schema defining constraints for the array.- Returns:
- An array specification for objects based on the specified predicate and size constraints.
-
arrayOfObjSuchThat
Returns a specification for a non-nullable array of objects that satisfies the given predicate.- Parameters:
predicate
- The predicate that the array must satisfy.- Returns:
- An array specification for objects based on the specified predicate.
-
integer
Returns a specification for a non-nullable integer number that satisfies the given predicate.- Parameters:
predicate
- The predicate that the integer must satisfy.- Returns:
- A specification for integer numbers based on the specified predicate.
-
arrayOfStrSuchThat
Returns a specification for a non-nullable array of strings that satisfies the given predicate.- Parameters:
predicate
- The predicate that the array must satisfy.- Returns:
- An array specification for strings based on the specified predicate.
-
array
Returns a specification for a non-nullable array, where each element of the array satisfies the given predicate.- Parameters:
predicate
- The predicate that each value in the array must satisfy.- Returns:
- An array specification for values based on the specified predicate.
-
arrayOfLong
Returns a specification for a non-nullable array of long numbers, where each element of the array satisfies the given predicate.- Parameters:
predicate
- The predicate that each long number in the array must satisfy.- Returns:
- An array specification for long numbers based on the specified predicate.
-
arrayOfLong
Returns a specification for a non-nullable array of long numbers, where each element of the array satisfies the given predicate. The array must satisfy the given schema (min and max item, unique elements etc).- Parameters:
predicate
- The predicate that each long number in the array must satisfy.schema
- The schema defining constraints for the array.- Returns:
- An array specification for long numbers based on the specified predicate.
-
arrayOfBoolSuchThat
Returns a specification for a non-nullable array of booleans that satisfies the given predicate.- Parameters:
predicate
- The predicate that the array must satisfy.- Returns:
- An array specification for booleans based on the specified predicate.
-
arrayOfDoubleSuchThat
Returns a specification for a non-nullable array of double that satisfies the given predicate.- Parameters:
predicate
- The predicate that the array must satisfy.- Returns:
- An array specification for double based on the specified predicate.
-
longInteger
Returns a specification for a non-nullable long number that satisfies the given predicate.- Parameters:
predicate
- The predicate that the long number must satisfy.- Returns:
- A specification for long numbers based on the specified predicate.
-
longInteger
Returns a specification for a non-nullable long number that satisfies the given schema.- Parameters:
schema
- The schema the long number must satisfy.- Returns:
- A specification for long numbers based on the specified schema.
-
doubleNumber
Returns a specification for a non-nullable double number that satisfies the given predicate.- Parameters:
predicate
- The predicate that the double number must satisfy.- Returns:
- A specification for long numbers based on the specified predicate.
-
decimal
Returns a specification for a non-nullable decimal number that satisfies the given predicate.- Parameters:
predicate
- The predicate that the decimal number must satisfy.- Returns:
- A specification for decimal numbers based on the specified predicate.
-
decimal
Returns a specification for a non-nullable decimal number that satisfies the given schema- Parameters:
schema
- The schema defining constraints for the decimal number.- Returns:
- A specification for decimal numbers based on the specified schema.
-
bigInteger
Returns a specification for a non-nullable big integer number that satisfies the given predicate.- Parameters:
predicate
- The predicate that the integral number must satisfy.- Returns:
- A specification for integral numbers based on the specified predicate.
-
bigInteger
Returns a specification for a non-nullable big integer number that satisfies the given schema.- Parameters:
schema
- The schema defining constraints for the big integer number.- Returns:
- A specification for integral numbers based on the specified schema.
-
arrayOfStr
Returns a specification for a non-nullable array of strings, where each element of the array satisfies the given predicate.- Parameters:
predicate
- The predicate that each string in the array must satisfy.- Returns:
- An array specification for strings based on the specified predicate.
-
arrayOfStr
Returns a specification for a non-nullable array of strings, where each element of the array satisfies the given schema.- Parameters:
schema
- The schema that each element of the array must satisfy.- Returns:
- An array specification for strings based on the specified predicate and size constraints.
-
arrayOfStr
Returns a specification for a non-nullable array of strings, where each element of the array satisfies the given predicate. The array must satisfy the given schema (min and max item, unique elements etc).- Parameters:
predicate
- The predicate that each string in the array must satisfy.arraySchema
- The schema defining constraints for the array.- Returns:
- An array specification for strings based on the specified predicate and size constraints.
-
any
Returns a specification that accepts any JSON value for which the given predicate evaluates to true.- Parameters:
predicate
- The predicate that determines whether a JSON value is accepted.- Returns:
- A specification that validates JSON values based on the specified predicate.
-
binary
Returns a specification for a non-nullable binary data that satisfies the given predicate.- Parameters:
predicate
- The predicate the JSON binary data is tested on.- Returns:
- A specification that enforces the specified condition for JSON binary data.
- See Also:
-
instant
Returns a specification for a non-nullable instant that satisfies the given predicate.- Parameters:
predicate
- The predicate the JSON instant is tested on.- Returns:
- A specification that enforces the specified condition for JSON instants.
-
instant
Returns a specification for a non-nullable JSON instant that satisfies the given schema.- Parameters:
schema
- The schema the instant must satisfy.- Returns:
- A specification that enforces the specified condition for JSON long numbers.
-
obj
Returns a specification for a non-nullable object that satisfies the given predicate.- Parameters:
predicate
- The predicate the object is tested on.- Returns:
- A specification that enforces the specified condition for JSON objects.
-
arrayOfLongSuchThat
Returns a specification for a non-nullable array of long numbers that satisfies the given predicate.- Parameters:
predicate
- The predicate the array is tested on.- Returns:
- An array specification that enforces the specified condition for arrays of long numbers.
-
arraySuchThat
Returns a specification for a non-nullable array that satisfies the given predicate.- Parameters:
predicate
- The predicate the array is tested on.- Returns:
- An array specification that enforces the specified condition for arrays.
-
arrayOfInt
Returns a specification for a non-nullable array of integer numbers, where each element of the array satisfies the given predicate.- Parameters:
predicate
- The predicate each integer number of the array is tested on.- Returns:
- An array specification that enforces the specified condition for integer elements.
-
arrayOfInt
Returns a specification for a non-nullable array of integer numbers, where each element of the array satisfies the given predicate.- Parameters:
predicate
- The predicate each integer number of the array is tested on.arraySchema
- The schema defining constraints for the array.- Returns:
- An array specification that enforces the specified conditions.
-
tuple
Returns a tuple specification where each nth element of the tuple is specified by the nth given spec.- Parameters:
spec
- The specification for the first element.others
- The specifications for the rest of the elements.- Returns:
- A specification for a tuple that enforces the specified structure.
-
oneValOf
Returns a specification that validates if a JSON value is one of the given possible values.- Type Parameters:
O
- The type of the possible JSON values (subtype of JsValue).- Parameters:
cons
- The list of possible JSON values.- Returns:
- A specification that checks if a JSON value matches one of the provided values.
-
oneValOf
Returns a specification that validates if a JSON value is one of the given possible values.- Type Parameters:
O
- The type of the possible JSON values (subtype of JsValue).- Parameters:
elem
- The first possible JSON value.others
- Additional possible JSON values.- Returns:
- A specification that checks if a JSON value matches one of the provided values.
-
oneSpecOf
Returns a specification that validates if a JSON value is one of the given possible specifications.- Parameters:
specs
- The list of possible JSON specifications.- Returns:
- A specification that checks if a JSON value matches one of the provided specifications.
-
oneSpecOf
Returns a specification that validates if a JSON value is one of the given possible specifications.- Parameters:
elem
- The first possible JSON specification.others
- Additional possible JSON specifications.- Returns:
- A specification that checks if a JSON value matches one of the provided specifications.
-
oneStringOf
Returns a specification that validates if a JSON value is one of the given possible symbols.- Parameters:
cons
- The list of possible JSON values.- Returns:
- A specification that checks if a JSON value matches one of the provided values.
-
oneStringOf
Returns a specification that validates if a JSON value is one of the given possible symbols.- Parameters:
elem
- The first possible symbol value.others
- Additional possible symbol values.- Returns:
- A specification that checks if a JSON value matches one of the provided symbol values.
-
mapOfLong
Returns a specification that validates that the JSON is an object, and the value of each key is a long number.- Returns:
- A JSON specification for objects with long number values.
-
mapOfInteger
Returns a specification that validates that the JSON is an object, and the value of each key is an integer.- Returns:
- A JSON specification for objects with integer values.
-
mapOfBigInteger
Returns a specification that validates that the JSON is an object, and the value of each key is a big integer.- Returns:
- A JSON specification for objects with big integer values.
-
mapOfBigInteger
Returns a specification that validates that the JSON is an object, and the value of each key is a big integer that satisfies the given schema.- Parameters:
schema
- the schema that each element of the map must satisfy- Returns:
- A JSON specification for objects with big integer values.
-
mapOfBinary
Returns a specification that validates that the JSON is an object, and the value of each key is a binary.- Returns:
- A JSON specification for objects with binary values.
-
mapOfDouble
Returns a specification that validates that the JSON is an object, and the value of each key is a double.- Returns:
- A JSON specification for objects with double values.
-
mapOfDouble
Returns a specification that validates that the JSON is an object, and the value of each key is a double that satisfies the given schema.- Parameters:
doubleSchema
- the schema that each element of the map must satisfy- Returns:
- A JSON specification for objects with double values.
-
mapOfDecimal
Returns a specification that validates that the JSON is an object, and the value of each key is a decimal number.- Returns:
- A JSON specification for objects with decimal number values.
-
mapOfDecimal
Returns a specification that validates that the JSON is an object, and the value of each key is a decimal number that satisfies the given schema.- Parameters:
decimalSchema
- the schema that each element of the map must satisfy- Returns:
- A JSON specification for objects with decimal number values.
-
mapOfBool
Returns a specification that validates that the JSON is an object, and the value of each key is a boolean.- Returns:
- A JSON specification for objects with boolean values.
-
mapOfInstant
Returns a specification that validates that the JSON is an object, and the value of each key is an instant.- Returns:
- A JSON specification for objects with instant values.
-
mapOfInstant
Returns a specification that validates that the JSON is an object, and the value of each key is an instant that satifies the given schema.- Parameters:
instantSchema
- the schema that each element of the map must satisfy- Returns:
- A JSON specification for objects with instant values.
-
mapOfObj
Returns a specification that validates that the JSON is an object, and the value of each key is an object.- Parameters:
spec
- the spec of the values of the map- Returns:
- A JSON specification for objects with object values.
-
mapOfStr
Returns a specification that validates that the JSON is an object, and the value of each key is a string.- Returns:
- A JSON specification for objects with string values.
-
mapOfStr
-
mapOfSpec
Returns a specification that validates that the JSON is an object, and the value of each key is a value that conforms the given spec.- Parameters:
spec
- the spec of the values- Returns:
- A JSON specification for maps.
-
arrayOfSpec
Returns a specification that validates that the JSON is an array, and the value of each element is a value that conforms the given spec.- Parameters:
spec
- the spec of the elements- Returns:
- A JSON specification for arrays.
-
arrayOfSpec
Returns a specification that validates that the JSON is an array, and the value of each element is a value that conforms the given spec.- Parameters:
spec
- the spec of the elementsarraySchema
- the schema that the array must satisfy- Returns:
- A JSON specification for arrays.
-
ofNamedSpec
Returns a named spec from the cache based on the provided name. Named specs are created using theJsObjSpecBuilder
and are cached for efficient retrieval and use in recursive specifications.Named specs represent reusable specifications that can be referenced in other specs, allowing for the creation of recursive data structures. Example usage:
var spec = JsObjSpecBuilder.withName("person") .build(JsObjSpec.of("name", JsSpecs.str(), "age", JsSpecs.integer(), "father", JsSpecs.ofNamedSpec("person") ) .withOptKeys("father") );
- Parameters:
name
- The name of the named spec to retrieve from the cache.- Returns:
- A named spec with the specified name.
- See Also:
-
ofNamedSpec
Creates and caches a named spec.- Parameters:
name
- The name of the named spec.spec
- The JsSpec to be associated with the named spec.- Returns:
- A named spec with the specified name.
-