Skip to content

Add nmos::validate_node_settings/validate_registry_settings#2

Merged
jonathan-r-thorpe merged 1 commit into
jonathan-r-thorpe:nmos-mxl-testfrom
garethsb:validate-settings-schema
Jun 1, 2026
Merged

Add nmos::validate_node_settings/validate_registry_settings#2
jonathan-r-thorpe merged 1 commit into
jonathan-r-thorpe:nmos-mxl-testfrom
garethsb:validate-settings-schema

Conversation

@garethsb
Copy link
Copy Markdown
Collaborator

Adds runtime validation of the known properties in nmos::settings, so that problems in user-supplied config.json (or command-line settings) are reported clearly up front instead of as bare json_exceptions later from field accessors. Validation is implemented as JSON schemas embedded in the source, composed via cross-schema $refs and run through the existing cpprest json_validator. Errors are reported as web::json::json_exception with a JSON pointer to the offending key and a description of the failed constraint, e.g.

  JSON error: schema validation failed at /ptp_domain_number - instance
  exceeds maximum of 127 JSON - 200

A fragment of NMOS value-type definitions (uuid, rational, interlaceMode, colorspace, transferCharacteristic, colorSampling, tags, ...) is exposed via nmos::details::settings_definitions_schema() so that application code can compose its own settings JSON schema and reuse the same canonical types. nmos-cpp-node uses this to implement validate_node_implementation_settings for its additional impl::fields::* settings.

Both example apps now validate settings (and abort with a clear error) before inserting run-time defaults and before any other field access.

Adds runtime validation of the known properties in nmos::settings, so that
problems in user-supplied config.json (or command-line settings) are reported
clearly up front instead of as bare json_exceptions later from field
accessors. Validation is implemented as JSON schemas embedded in the source,
composed via cross-schema $refs and run through the existing cpprest
json_validator. Errors are reported as web::json::json_exception with a JSON
pointer to the offending key and a description of the failed constraint, e.g.

  JSON error: schema validation failed at /ptp_domain_number - instance
  exceeds maximum of 127 JSON - 200

A fragment of NMOS value-type definitions (uuid, rational, interlaceMode,
colorspace, transferCharacteristic, colorSampling, tags, ...) is exposed via
nmos::details::settings_definitions_schema() so that application code can
compose its own settings JSON schema and reuse the same canonical types.
nmos-cpp-node uses this to implement impl::validate_node_settings for its
additional impl::fields::* settings.

Both example apps now validate settings (and abort with a clear error)
before inserting run-time defaults and before any other field access.
Copy link
Copy Markdown
Owner

@jonathan-r-thorpe jonathan-r-thorpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jonathan-r-thorpe jonathan-r-thorpe merged commit 41b6a58 into jonathan-r-thorpe:nmos-mxl-test Jun 1, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants