Module json_values

Class JsSpecs

java.lang.Object
jsonvalues.spec.JsSpecs

public final class JsSpecs extends Object
The `JsSpecs` class provides a collection of static factory methods for creating JSON specifications (JsSpec). These specifications are used to define validation rules and constraints for JSON data structures to ensure that they conform to expected formats and patterns.

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:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final JsSpec
    false constant spec
    static final JsSpec
    true constant spec
  • Method Summary

    Modifier and Type
    Method
    Description
    static JsSpec
    any()
    spec that is conformed by any value
    static JsSpec
    any(Predicate<JsValue> predicate)
    Returns a specification that accepts any JSON value for which the given predicate evaluates to true.
    non-nullable array spec
    array(Predicate<JsValue> predicate)
    Returns a specification for a non-nullable array, where each element of the array satisfies the given predicate.
    non-nullable array of integral numbers spec
    arrayOfBigInt(int minLength, int maxLength)
    Returns a specification for an array of big integers with a specified minimum and maximum length.
    Returns a specification for a non-nullable array of integral numbers, where each element of the array satisfies the given predicate.
    arrayOfBigInt(Predicate<BigInteger> predicate, int minLength, int maxLength)
    Returns a specification for a non-nullable array of integral numbers, where each element of the array satisfies the given predicate.
    Returns a specification for a non-nullable array of integral numbers, where each element of the array satisfies the given predicate.
    non-nullable array of booleans spec
    arrayOfBool(int minLength, int maxLength)
    Returns a specification for an array of booleans with a specified minimum and maximum length.
    Returns a specification for a non-nullable array of booleans that satisfies the given predicate.
    non-nullable array of decimal numbers spec
    arrayOfDec(int minLength, int maxLength)
    Returns a specification for an array of decimal numbers with a specified minimum and maximum length.
    Returns a specification for a non-nullable array of decimal numbers, where each element of the array satisfies the given predicate.
    arrayOfDec(Predicate<BigDecimal> predicate, int minLength, int maxLength)
    Returns a specification for a non-nullable array of decimal numbers, where each element of the array satisfies the given predicate.
    Returns a specification for a non-nullable array of decimal numbers, where each element of the array satisfies the given predicate.
    non-nullable array of integer numbers spec
    arrayOfInt(int minLength, int maxLength)
    Returns a specification for an array of integers with a specified minimum and maximum length.
    Returns a specification for a non-nullable array of integer numbers, where each element of the array satisfies the given predicate.
    arrayOfInt(IntPredicate predicate, int minLength, int maxLength)
    Returns a specification for a non-nullable array of integer numbers, where each element of the array satisfies the given predicate.
    Returns a specification for a non-nullable array of integer numbers, where each element of the array satisfies the given predicate.
    non-nullable array of long numbers spec
    arrayOfLong(int minLength, int maxLength)
    Returns a specification for an array of long numbers with a specified minimum and maximum length.
    Returns a specification for a non-nullable array of long numbers, where each element of the array satisfies the given predicate.
    arrayOfLong(LongPredicate predicate, int minLength, int maxLength)
    Returns a specification for a non-nullable array of long numbers, where each element of the array satisfies the given predicate.
    Returns a specification for a non-nullable array of long numbers that satisfies the given predicate.
    non-nullable array of numbers spec
    arrayOfNumber(int minLength, int maxLength)
    Returns a specification for an array of numbers with a specified minimum and maximum length.
    Returns a specification for a non-nullable array of numbers, where each element of the array satisfies the given predicate.
    arrayOfNumber(Predicate<JsNumber> predicate, int minLength, int maxLength)
    Returns a specification for a non-nullable array of numbers, where each element of the array satisfies the given predicate.
    Returns a specification for a non-nullable array of numbers, where each element of the array satisfies the given predicate.
    non-nullable array of objects spec
    arrayOfObj(int minLength, int maxLength)
    Returns a specification for an array of objects with a specified minimum and maximum length.
    Returns a specification for a non-nullable array of objects, where each element of the array satisfies the given predicate.
    arrayOfObj(Predicate<JsObj> predicate, int minLength, int maxLength)
    Returns a specification for a non-nullable array of objects, where each element of the array satisfies the given predicate.
    Returns a required and non-nullable specification for an array of objects that conform to the given object specification.
    arrayOfObjSpec(JsObjSpec spec, int minLength, int maxLength)
    Returns a required and non-nullable specification for an array of objects that conform to the given object specification.
    Returns a specification for a non-nullable array of objects that satisfies the given predicate.
    non-nullable array of strings spec
    arrayOfStr(int minLength, int maxLength)
    Returns a specification for an array of strings with a specified minimum and maximum length.
    Returns a specification for a non-nullable array of strings, where each element of the array satisfies the given predicate.
    arrayOfStr(Predicate<String> predicate, int minLength, int maxLength)
    Returns a specification for a non-nullable array of strings, where each element of the array satisfies the given predicate.
    Returns a specification for a non-nullable array of strings, where each element of the array satisfies the given predicate.
    Returns a specification for a non-nullable array that satisfies the given predicate.
    static JsSpec
    non-nullable integral number
    static JsSpec
    Returns a specification for a non-nullable integral number that satisfies the given predicate.
    static JsSpec
    non-nullable binary spec
    static JsSpec
    binary(Predicate<byte[]> predicate)
    Returns a specification for a non-nullable JSON binary data that satisfies the given predicate.
    static JsSpec
    non-nullable boolean
    static JsSpec
    cons(JsValue value)
    Returns a required and non-nullable specification that specifies a constant value.
    static JsSpec
    non-nullable decimal number
    static JsSpec
    Returns a specification for a non-nullable decimal number that satisfies the given predicate.
    static JsSpec
    non-nullable array spec
    static JsSpec
    Returns a specification for a non-nullable JSON instant that satisfies the given predicate.
    static JsSpec
    non-nullable integer number
    static JsSpec
    integer(IntPredicate predicate)
    Returns a specification for a non-nullable integer number that satisfies the given predicate.
    static JsSpec
    non-nullable long number
    static JsSpec
    Returns a specification for a non-nullable long number that satisfies the given predicate.
    static JsSpec
    Returns a specification that validates that the JSON is an object, and the value of each key is an array.
    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
    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
    Returns a specification that validates that the JSON is an object, and the value of each key is an instant.
    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 string.
    static JsSpec
    Returns a non-nullable number specification.
    static JsSpec
    Returns a specification for a non-nullable number, where the number satisfies the given predicate.
    static JsSpec
    obj()
    non-nullable json object spec
    static JsSpec
    obj(Predicate<JsObj> predicate)
    Returns a specification for a non-nullable JSON object that satisfies the given predicate.
    static <O extends JsValue>
    JsSpec
    oneOf(List<O> cons)
    Returns a specification that validates if a JSON value is one of the given possible values.
    static JsSpec
    str()
    non-nullable string
    static JsSpec
    str(int min, int max)
    Returns a non-nullable string specification that validates strings based on their length within the specified range.
    static JsSpec
    str(Predicate<String> predicate)
    Returns a specification for a non-nullable string, where the string satisfies the given predicate.
    static JsSpec
    str(Pattern pattern)
    Returns a non-nullable string specification with the specified regular expression pattern.
    static jsonvalues.spec.JsTupleSpec
    tuple(JsSpec spec, JsSpec... others)
    Returns a tuple specification where each nth element of the tuple is specified by the nth given spec.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • TRUE

      public static final JsSpec TRUE
      true constant spec
    • FALSE

      public static final JsSpec FALSE
      false constant spec
  • Method Details

    • arrayOfNumber

      public static JsArraySpec arrayOfNumber()
      non-nullable array of numbers spec
      Returns:
      a spec
    • arrayOfDec

      public static JsArraySpec arrayOfDec()
      non-nullable array of decimal numbers spec
      Returns:
      a spec
    • arrayOfBigInt

      public static JsArraySpec arrayOfBigInt()
      non-nullable array of integral numbers spec
      Returns:
      a spec
    • arrayOfObj

      public static JsArraySpec arrayOfObj()
      non-nullable array of objects spec
      Returns:
      a spec
    • arrayOfBool

      public static JsArraySpec arrayOfBool()
      non-nullable array of booleans spec
      Returns:
      a spec
    • instant

      public static JsSpec instant()
      non-nullable array spec
      Returns:
      a spec
    • arrayOfLong

      public static JsArraySpec arrayOfLong()
      non-nullable array of long numbers spec
      Returns:
      a spec
    • arrayOfInt

      public static JsArraySpec arrayOfInt()
      non-nullable array of integer numbers spec
      Returns:
      a spec
    • arrayOfStr

      public static JsArraySpec arrayOfStr()
      non-nullable array of strings spec
      Returns:
      a spec
    • binary

      public static JsSpec binary()
      non-nullable binary spec
      Returns:
      a spec
      See Also:
    • bigInteger

      public static JsSpec bigInteger()
      non-nullable integral number
      Returns:
      a spec
    • longInteger

      public static JsSpec longInteger()
      non-nullable long number
      Returns:
      a spec
    • bool

      public static JsSpec bool()
      non-nullable boolean
      Returns:
      a spec
    • decimal

      public static JsSpec decimal()
      non-nullable decimal number
      Returns:
      a spec
    • integer

      public static JsSpec integer()
      non-nullable integer number
      Returns:
      a spec
    • obj

      public static JsSpec obj()
      non-nullable json object spec
      Returns:
      a spec
    • array

      public static JsArraySpec array()
      non-nullable array spec
      Returns:
      a spec
    • any

      public static JsSpec any()
      spec that is conformed by any value
      Returns:
      a spec
    • str

      public static JsSpec str()
      non-nullable string
      Returns:
      a spec
    • str

      public static JsSpec str(int min, int max)
      Returns a non-nullable string specification that validates strings based on their length within the specified range.
      Parameters:
      min - The minimum allowed length for strings (inclusive).
      max - The maximum allowed length for strings (inclusive).
      Returns:
      A specification for strings that have a length within the specified range.
      Throws:
      IllegalArgumentException - If the provided min is negative, max is non-positive, or min is greater than max.
    • str

      public static JsSpec str(Pattern pattern)
      Returns a non-nullable string specification with the specified regular expression pattern.
      Parameters:
      pattern - The regular expression pattern to match strings against.
      Returns:
      A specification for strings that match the given pattern.
      Throws:
      NullPointerException - If the provided pattern is null.
    • number

      public static JsSpec number()
      Returns a non-nullable number specification.
      Returns:
      A specification for numbers.
    • arrayOfInt

      public static JsArraySpec arrayOfInt(int minLength, int maxLength)
      Returns a specification for an array of integers with a specified minimum and maximum length.
      Parameters:
      minLength - The minimum length of the array (inclusive).
      maxLength - The maximum length of the array (inclusive).
      Returns:
      A specification for an array of integers with the specified length constraints.
      Throws:
      IllegalArgumentException - If the maximum length is less than the minimum length.
    • arrayOfBigInt

      public static JsArraySpec arrayOfBigInt(int minLength, int maxLength)
      Returns a specification for an array of big integers with a specified minimum and maximum length.
      Parameters:
      minLength - The minimum length of the array (inclusive).
      maxLength - The maximum length of the array (inclusive).
      Returns:
      A specification for an array of big integers with the specified length constraints.
      Throws:
      IllegalArgumentException - If the maximum length is less than the minimum length.
    • arrayOfNumber

      public static JsArraySpec arrayOfNumber(int minLength, int maxLength)
      Returns a specification for an array of numbers with a specified minimum and maximum length.
      Parameters:
      minLength - The minimum length of the array (inclusive).
      maxLength - The maximum length of the array (inclusive).
      Returns:
      A specification for an array of numbers with the specified length constraints.
      Throws:
      IllegalArgumentException - If the maximum length is less than the minimum length.
    • arrayOfObj

      public static JsArraySpec arrayOfObj(int minLength, int maxLength)
      Returns a specification for an array of objects with a specified minimum and maximum length.
      Parameters:
      minLength - The minimum length of the array (inclusive).
      maxLength - The maximum length of the array (inclusive).
      Returns:
      A specification for an array of objects with the specified length constraints.
      Throws:
      IllegalArgumentException - If the maximum length is less than the minimum length.
    • arrayOfDec

      public static JsArraySpec arrayOfDec(int minLength, int maxLength)
      Returns a specification for an array of decimal numbers with a specified minimum and maximum length.
      Parameters:
      minLength - The minimum length of the array (inclusive).
      maxLength - The maximum length of the array (inclusive).
      Returns:
      A specification for an array of decimal numbers with the specified length constraints.
      Throws:
      IllegalArgumentException - If the maximum length is less than the minimum length.
    • arrayOfBool

      public static JsArraySpec arrayOfBool(int minLength, int maxLength)
      Returns a specification for an array of booleans with a specified minimum and maximum length.
      Parameters:
      minLength - The minimum length of the array (inclusive).
      maxLength - The maximum length of the array (inclusive).
      Returns:
      A specification for an array of booleans with the specified length constraints.
      Throws:
      IllegalArgumentException - If the maximum length is less than the minimum length.
    • arrayOfStr

      public static JsArraySpec arrayOfStr(int minLength, int maxLength)
      Returns a specification for an array of strings with a specified minimum and maximum length.
      Parameters:
      minLength - The minimum length of the array (inclusive).
      maxLength - The maximum length of the array (inclusive).
      Returns:
      A specification for an array of strings with the specified length constraints.
      Throws:
      IllegalArgumentException - If the maximum length is less than the minimum length.
    • arrayOfLong

      public static JsArraySpec arrayOfLong(int minLength, int maxLength)
      Returns a specification for an array of long numbers with a specified minimum and maximum length.
      Parameters:
      minLength - The minimum length of the array (inclusive).
      maxLength - The maximum length of the array (inclusive).
      Returns:
      A specification for an array of long numbers with the specified length constraints.
      Throws:
      IllegalArgumentException - If the maximum length is less than the minimum length.
    • arrayOfObjSpec

      public static JsArraySpec arrayOfObjSpec(JsObjSpec spec)
      Returns a required and non-nullable specification for an array of objects that conform to the given object specification.
      Parameters:
      spec - The object specification that every object in the array must conform to.
      Returns:
      A specification that enforces an array of objects conforming to the provided object specification.
    • arrayOfObjSpec

      public static JsArraySpec arrayOfObjSpec(JsObjSpec spec, int minLength, int maxLength)
      Returns a required and non-nullable specification for an array of objects that conform to the given object specification.
      Parameters:
      spec - The object specification that every object in the array must conform to.
      minLength - The minimum length of the array (inclusive).
      maxLength - The maximum length of the array (inclusive).
      Returns:
      A specification that enforces an array of objects conforming to the provided object specification.
      Throws:
      IllegalArgumentException - If the maximum length is less than the minimum length.
      See Also:
    • cons

      public static JsSpec cons(JsValue value)
      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.
    • str

      public static JsSpec str(Predicate<String> predicate)
      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.
    • number

      public static JsSpec number(Predicate<JsNumber> predicate)
      Returns a specification for a non-nullable number, where the number satisfies the given predicate.
      Parameters:
      predicate - The predicate that the number must satisfy.
      Returns:
      A specification for numbers based on the specified predicate.
    • arrayOfIntSuchThat

      public 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.
      Parameters:
      predicate - The predicate that the entire array must satisfy.
      Returns:
      An array specification for integer numbers based on the specified predicate.
    • arrayOfDec

      public static 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.
      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

      public static JsArraySpec arrayOfDec(Predicate<BigDecimal> predicate, int minLength, int maxLength)
      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.
      minLength - The minimum size of the array (inclusive).
      maxLength - The maximum size of the array (inclusive).
      Returns:
      An array specification for decimal numbers based on the specified predicate and size range.
      Throws:
      IllegalArgumentException - If the maximum length is lower than the minimum length.
    • arrayOfDecSuchThat

      public 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.
      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

      public static 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.
      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

      public static JsArraySpec arrayOfBigInt(Predicate<BigInteger> predicate, int minLength, int maxLength)
      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.
      minLength - The minimum size of the array (inclusive).
      maxLength - The maximum size of the array (inclusive).
      Returns:
      An array specification for integral numbers based on the specified predicate and size constraints.
      Throws:
      IllegalArgumentException - If the maximum size is lower than the minimum size.
    • arrayOfBigIntSuchThat

      public 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.
      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.
    • arrayOfNumber

      public static JsArraySpec arrayOfNumber(Predicate<JsNumber> predicate)
      Returns a specification for a non-nullable array of numbers, where each element of the array satisfies the given predicate.
      Parameters:
      predicate - The predicate that each number in the array must satisfy.
      Returns:
      An array specification for numbers based on the specified predicate.
    • arrayOfNumber

      public static JsArraySpec arrayOfNumber(Predicate<JsNumber> predicate, int minLength, int maxLength)
      Returns a specification for a non-nullable array of numbers, where each element of the array satisfies the given predicate.
      Parameters:
      predicate - The predicate that each number in the array must satisfy.
      minLength - The minimum size of the array (inclusive).
      maxLength - The maximum size of the array (inclusive).
      Returns:
      An array specification for numbers based on the specified predicate.
      Throws:
      IllegalArgumentException - If maxLength is less than minLength.
    • arrayOfNumberSuchThat

      public static JsArraySpec arrayOfNumberSuchThat(Predicate<JsArray> predicate)
      Returns a specification for a non-nullable array of numbers, where each element of the array satisfies the given predicate.
      Parameters:
      predicate - The predicate that each number in the array must satisfy.
      Returns:
      An array specification for numbers based on the specified predicate.
    • arrayOfObj

      public static 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.
      Parameters:
      predicate - The predicate that each object in the array must satisfy.
      Returns:
      An array specification for objects based on the specified predicate.
    • arrayOfObj

      public static JsArraySpec arrayOfObj(Predicate<JsObj> predicate, int minLength, int maxLength)
      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.
      minLength - The minimum size of the array (inclusive).
      maxLength - The maximum size of the array (inclusive).
      Returns:
      An array specification for objects based on the specified predicate and size constraints.
      Throws:
      IllegalArgumentException - If the maximum length is less than the minimum length.
    • arrayOfObjSuchThat

      public static JsArraySpec arrayOfObjSuchThat(Predicate<JsArray> predicate)
      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

      public static JsSpec integer(IntPredicate predicate)
      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

      public static JsArraySpec arrayOfStrSuchThat(Predicate<JsArray> predicate)
      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 the array must satisfy.
      Returns:
      An array specification for strings based on the specified predicate.
    • array

      public static JsArraySpec array(Predicate<JsValue> predicate)
      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

      public static 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.
      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

      public static JsArraySpec arrayOfLong(LongPredicate predicate, int minLength, int maxLength)
      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.
      minLength - The minimum size of the array (inclusive).
      maxLength - The maximum size of the array (inclusive).
      Returns:
      An array specification for long numbers based on the specified predicate.
      Throws:
      IllegalArgumentException - If maxLength is less than minLength.
    • arrayOfBoolSuchThat

      public static JsArraySpec arrayOfBoolSuchThat(Predicate<JsArray> predicate)
      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.
    • longInteger

      public static JsSpec longInteger(LongPredicate predicate)
      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.
    • decimal

      public static JsSpec decimal(Predicate<BigDecimal> predicate)
      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.
    • bigInteger

      public static JsSpec bigInteger(Predicate<BigInteger> predicate)
      Returns a specification for a non-nullable integral 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.
    • arrayOfStr

      public static 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.
      Parameters:
      predicate - The predicate that each string in the array must satisfy.
      Returns:
      An array specification for strings based on the specified predicate.
    • arrayOfStr

      public static JsArraySpec arrayOfStr(Predicate<String> predicate, int minLength, int maxLength)
      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.
      minLength - The minimum size of the array (inclusive).
      maxLength - The maximum size of the array (inclusive).
      Returns:
      An array specification for strings based on the specified predicate and size constraints.
      Throws:
      IllegalArgumentException - If maxLength is less than minLength.
    • any

      public static JsSpec any(Predicate<JsValue> predicate)
      Returns a specification that accepts any JSON value for which the given predicate evaluates to true. When the type is not specified by the spec, positive numbers are parsed as Long by default, which has to be taken into account when defining the condition.
      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

      public static JsSpec binary(Predicate<byte[]> predicate)
      Returns a specification for a non-nullable JSON 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

      public static JsSpec instant(Predicate<Instant> predicate)
      Returns a specification for a non-nullable JSON 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.
    • obj

      public static JsSpec obj(Predicate<JsObj> predicate)
      Returns a specification for a non-nullable JSON object that satisfies the given predicate.
      Parameters:
      predicate - The predicate the JSON object is tested on.
      Returns:
      A specification that enforces the specified condition for JSON objects.
    • arrayOfLongSuchThat

      public static JsArraySpec arrayOfLongSuchThat(Predicate<JsArray> predicate)
      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

      public static JsArraySpec arraySuchThat(Predicate<JsArray> predicate)
      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

      public static 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.
      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

      public static JsArraySpec arrayOfInt(IntPredicate predicate, int minLength, int maxLength)
      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.
      minLength - The minimum size of the array (inclusive).
      maxLength - The maximum size of the array (inclusive).
      Returns:
      An array specification that enforces the specified conditions.
      Throws:
      IllegalArgumentException - If maxLength is less than minLength.
    • tuple

      public static jsonvalues.spec.JsTupleSpec tuple(JsSpec spec, JsSpec... others)
      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.
    • oneOf

      public static <O extends JsValue> JsSpec oneOf(List<O> cons)
      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.
    • mapOfLong

      public static JsSpec 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

      public static JsSpec 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

      public static JsSpec 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.
    • mapOfDecimal

      public static JsSpec 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.
    • mapOfBool

      public static JsSpec 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

      public static JsSpec 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.
    • mapOfObj

      public static JsSpec mapOfObj()
      Returns a specification that validates that the JSON is an object, and the value of each key is an object.
      Returns:
      A JSON specification for objects with object values.
    • mapOfStr

      public static JsSpec 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.
    • mapOfArray

      public static JsSpec mapOfArray()
      Returns a specification that validates that the JSON is an object, and the value of each key is an array.
      Returns:
      A JSON specification for objects with array values.