You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It behaves like XPath's fn:error. Calling $error from an expression causes it to abort with the specified error message. This is useful for validating input data. If, for example, you require certain fields to be present in your JSON, you can check for them upfront and throw a meaningful error if they don't exist.
(
$assert := function($cond, $msg) {
$not($cond) ? $error($msg)
};
$assert(some.value % 2 = 0, "value must be an even number");
$assert($length(some.other.value) = 3, "value must be a 3 letter acronym");
$assert(another.value != null, "value cannot be null");
<-- main expression goes here -->
)
The text was updated successfully, but these errors were encountered:
This is a proposal for a new function:
It behaves like XPath's fn:error. Calling
$error
from an expression causes it to abort with the specified error message. This is useful for validating input data. If, for example, you require certain fields to be present in your JSON, you can check for them upfront and throw a meaningful error if they don't exist.The text was updated successfully, but these errors were encountered: