Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
maddenp-noaa committed Jan 8, 2025
1 parent 7acd969 commit deb723c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/uwtools/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ def validate(
"""
Check whether the specified config conforms to the specified JSON Schema spec.
If no config is specified, ``stdin`` is read and will be parsed as YAML and then validated. A
``dict`` or a ``YAMLConfig`` instance may also be provided for validation.
Specify at most one of config_data or config_path. If no config is specified, ``stdin`` is read
and will be parsed as YAML and then validated.
:param schema_file: The JSON Schema file to use for validation.
:param config_data: A config to validate.
:param config_path: A path to a file containing a config to validate.
:param stdin_ok: OK to read from ``stdin``?
:raises: TypeError if config_* arguments are not set appropriately.
:raises: TypeError if both config_* arguments specified.
:return: ``True`` if the YAML file conforms to the schema, ``False`` otherwise.
"""
_validate_check_config(config_data, config_path)
Expand Down
14 changes: 10 additions & 4 deletions src/uwtools/config/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,22 @@ def validate_internal(
"""
Validate a config against a uwtools-internal schema.
Specify at most one of config_data or config_path. If no config is specified, ``stdin`` is read
and will be parsed as YAML and then validated.
:param schema_name: Name of uwtools schema to validate the config against.
:param desc: A description of the config being validated, for logging.
:param config_data: A config to validate.
:param config_path: A path to a file containing a config to validate.
:raises: TypeError if config_* arguments are not set appropriately.
:raises: TypeError if both config_* arguments specified.
"""
validate_check_config(config_data, config_path)
log.info("Validating config against internal schema: %s", schema_name)
validate_external(
config_data=config_data,
config_path=config_path,
schema_file=internal_schema_file(schema_name),
desc=desc,
config_data=config_data,
config_path=config_path,
)


Expand All @@ -129,11 +132,14 @@ def validate_external(
"""
Validate a YAML config against the JSON Schema in the given schema file.
Specify at most one of config_data or config_path. If no config is specified, ``stdin`` is read
and will be parsed as YAML and then validated.
:param schema_file: The JSON Schema file to use for validation.
:param desc: A description of the config being validated, for logging.
:param config_data: A config to validate.
:param config_path: A path to a file containing a config to validate.
:raises: TypeError if config_* arguments are not set appropriately.
:raises: TypeError if both config_* arguments specified.
"""
validate_check_config(config_data, config_path)
config: JSONValueT
Expand Down

0 comments on commit deb723c

Please sign in to comment.