Members
(constant) RuleSchema
This Schema is the basis for all rule writing.
Each field with a value will be used as the placeholder for the field in the rule.
Each field requires a corresponding __field key with a text description of the field.
The standardized json-schema is not used here as it is far more complex than is necessary
for this use case.
Methods
addNewCase(ruleInput)
Adds a new i/o case to the rule JSON.
Parameters:
Name | Type | Description |
---|---|---|
ruleInput |
JSON | the rule. |
Returns:
The modified rule JSON.
addNewInputCondition(ruleInput)
Adds an input condition to the rule body.
Parameters:
Name | Type | Description |
---|---|---|
ruleInput |
JSON |
addNewOutputAssertion(ruleInput)
Adds a new output assertion to the rule body.
Parameters:
Name | Type | Description |
---|---|---|
ruleInput |
JSON |
checkSchema(schema)
Adds blank missing fields to a piece of content JSON, based on the fields present in the schema.
Throws an error if a field that is NOT in the schema is present in the content blob.
Parameters:
Name | Type | Description |
---|---|---|
schema |
JSON | A JSON blob containing a rule schema. |
- Source:
deepCopy(obj)
Returns a deep copy of a JSON object.
Parameters:
Name | Type | Description |
---|---|---|
obj |
JSON | The JSON object to replicate. |
- Source:
enforceSchema(schema, content, skipSchemaCheck)
Adds blank missing fields to a piece of content JSON, based on the fields present in the schema.
Throws an error if a field that is NOT in the schema is present in the content blob.
Parameters:
Name | Type | Description |
---|---|---|
schema |
JSON | A JSON blob containing the schema for the passed content |
content |
JSON | A JSON blob to be modified to fit the passed schema |
skipSchemaCheck |
boolean | For development: skip checkSchema tests for test simplicity. |
- Source:
enforceSchemaNoCheck(schema, content)
Adds blank missing fields to a piece of content JSON, based on the fields present in the schema.
Throws an error if a field that is NOT in the schema is present in the content blob.
Additionally, ignores schema enforcement.
Parameters:
Name | Type | Description |
---|---|---|
schema |
JSON | A JSON blob containing the schema for the passed content |
content |
JSON | A JSON blob to be modified to fit the passed schema |
- Source:
enforceSchemaWithTables(schema, content)
Adds blank missing fields to a piece of content JSON, based on the fields present in the schema.
Throws an error if a field that is NOT in the schema is present in the content blob.
Additionally, adds an empty table row for any object-tables.
Parameters:
Name | Type | Description |
---|---|---|
schema |
JSON | A JSON blob containing the schema for the passed content |
content |
JSON | A JSON blob to be modified to fit the passed schema |
- Source:
generateCaseValue(number)
Generates an input/output case ID from its numerical position in the cases.
Parameters:
Name | Type | Description |
---|---|---|
number |
int |
- Source:
generateCaseValueFromPrev(prevValue)
Generates an input/output case ID from the previous int/char combination.
Parameters:
Name | Type | Description |
---|---|---|
prevValue |
string |
- Source:
generateNewRule()
Generates a new rule, taking care to add presets where necessary.
isArray(x) → {Boolean}
Checks to see if the object is an Array.
Parameters:
Name | Type | Description |
---|---|---|
x |
Object | Object to test. |
Returns:
- Type
- Boolean
isObject(x) → {Boolean}
Checks to see if the object is a JSON object.
Parameters:
Name | Type | Description |
---|---|---|
x |
Object | Object to test. |
Returns:
- Type
- Boolean
isTable(x) → {Boolean}
Checks to see if the object is an XA table: an array with key-value JSON
objects. A table may not contain arrays or objects as table values.
Parameters:
Name | Type | Description |
---|---|---|
x |
Object | Object to test. |
Returns:
- Type
- Boolean
isValue(x) → {Boolean}
Checks to see if the object is an XA VALUE.
Parameters:
Name | Type | Description |
---|---|---|
x |
Object | Object to test. |
Returns:
- Type
- Boolean
normalizeValue(val)
Ensure numbers are stored in the proccesed JSON as numbers.
Parameters:
Name | Type | Description |
---|---|---|
val |
Object | A String or Number |
- Source:
pathifyJSON(document) → {Object}
Takes a document and transforms nested objects into string paths.
Parameters:
Name | Type | Description |
---|---|---|
document |
Object | A blob of incoming structured JSON data. |
- Source:
Returns:
Restructured version of the original document
- Type
- Object
prettyJSON(x) → {String}
Returns the stringified version of a JSON object.
Parameters:
Name | Type | Description |
---|---|---|
x |
Object | Input JSON object. |
- Source:
Returns:
Pretty-printed JSON string.
- Type
- String
xaType(obj) → {XA_TYPES}
Returns the XA_TYPE enumeration of the input object.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | A JSON value. |
Returns:
The enumerated type of the JSON value.
- Type
- XA_TYPES