Skip to content

Rule.io SDK


Rule.io SDK / rcml/src / validateJson

Function: validateJson()

validateJson(input, config?): Json

Defined in: rcml/src/email/validate-rcml-json.ts:154

Validate raw input as RCML content JSON.

When config is provided, only the node / mark types permitted by that FlavorConfig are accepted. Without config, the superset schema is used.

Parameters

input

unknown

The value to validate (typically a parsed JSON object).

config?

FlavorConfig

Optional flavor config restricting allowed node/mark types.

Returns

Json

The input cast to Json when valid.

Throws

When the input does not conform to the RCML JSON schema.

Example

ts
const doc = validateJson(JSON.parse(raw))
// doc is typed as Json