Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface PartialJSON

A constraint requiring the current value of the JSON topic to match the partially described value.

The code:

const factory = diffusion.updateConstraints();
const constraint = factory.jsonValue().with('/id', idValue).without('/cancellation');

creates a constraint for a JSON object with a specific ID value and no value for a 'cancellation' property.

Missing keys are matched differently to keys that are present with null values.

since

6.2

Hierarchy

Index

Methods

Methods

and

  • Returns a composed constraint that represents a logical AND of this constraint and another.

    throws

    an IllegalArgumentError if the composed constraint would be unsatisfiable

    Parameters

    • other: UpdateConstraint

      a constraint that will be logically-ANDed with this constraint

    Returns UpdateConstraint

    a composed constraint that represents a logical AND of this constraint and the other constraint

or

  • Returns a composed constraint that represents a logical OR of this constraint and another.

    throws

    an IllegalArgumentError if the composed constraint would be unsatisfiable

    Parameters

    • other: UpdateConstraint

      a constraint that will be logically-ORed with this constraint

    Returns UpdateConstraint

    a composed constraint that represents a logical OR of this constraint and the other constraint

with

  • Require a value at a specific position in the JSON object.

    This is equivalent to calling with(String, Operator, Object) with an operator of IS.

    deprecated

    since 6.10

            Rather use the <a href="partialjson.html#with">with(String, Operator, Object)</a>
            method with the <a href="../enums/updateconstraintoperator.html#is">IS</a> operator.
    throws

    an IllegalArgumentError if pointer is an invalid JSON Pointer expression or value cannot be serialised

    throws

    a NullValueError if any of the required arguments are null

    Parameters

    • pointer: string

      the pointer expression

    • value: any

      the value

    • Optional dataType: DataType<any, any, any>

      the optional type of the value

    Returns PartialJSON

    a new constraint

  • Compares a location within the JSON topic value to a specified value.

    If there is no value found at the specified pointer position, the constraint will be unsatisfied.

    If a String value is supplied and the operator is EQ or NE, the string representation of the topic value at the given pointer will be compared to the supplied value. If the value at the pointer position is not a string or number the constraint will be unsatisfied. Other operators (other than IS) are not permitted with String values.

    If a number value (Int64 or Double) is supplied the value will be compared with the number value at the topic location. This will work with JSON string or number values only. JSON strings can only be compared if they contain a value that can be parsed as a number. If a string value at the location cannot be parsed as a number, the constraint will be unsatisfied. Any of the operators (other than IS) can be used with such number comparisons. Decimal numbers can be compared with integral numbers so {@code 1} is equal to {@code 1.0}, {@code "1"}, or {@code "1.0"}.

    If a {@code null} value is supplied and the operator is EQ or NE, the topic value at the given pointer will be compared to JSON null. Other operators (other than IS) are not permitted with a {@code null} value.

    If a boolean value is supplied and the operator is EQ, the topic value at the given pointer will be compared to the boolean value. Other operators are not permitted with a boolean value.

    If the IS operator is specified the supplied value will be compared to the topic value for strict binary equality. In this case the value must be of type String, Int64, Double, Bytes, or {@code null}. This is slightly more efficient than the lenient comparisons described above.

    throws

    an IllegalArgumentError if pointer is an invalid JSON Pointer expression, the value cannot be serialised or the operator is invalid for the value type

    throws

    a NullValueError if any of the required arguments are null

    since

    6.10

    Parameters

    • pointer: string

      a JSON Pointer specifying the location of the {@code value} in the JSON object.

    • value: any

      the value

    • operator: UpdateConstraintOperator

      the operator that determines the type of comparison

    • Optional dataType: DataType<any, any, any>

    Returns PartialJSON

    a new constraint

without

  • Require a specific position in the JSON object to be empty.

    The pointer is a JSON Pointer syntax reference that should have no value in the JSON object. If the pointer parameter cannot be parsed as a JSON pointer an Error is thrown.

    The function returns a new PartialJSON object. The original object remains unmodified.

    throws

    an IllegalArgumentError if pointer is an invalid JSON Pointer expression

    throws

    a NullValueError if the pointer argument is null

    Parameters

    • pointer: string

      the pointer expression

    Returns PartialJSON

    a new constraint