wiz.validator¶
-
wiz.validator.validate_definition(data)[source]¶ Validate data mapping used to create a definition.
An error will be raised if the data mapping cannot be used to create an instance of
wiz.definition.Definition..Parameters: data – Mapping to validate. Raise: wiz.exception.IncorrectDefinitionif the data mapping is incorrect.
-
wiz.validator.validate_identifier_keyword(data, variant_index=None)[source]¶ Validate ‘identifier’ keyword within data mapping.
A correct data mapping should be in the form of:
{ "identifier": "foo" }
Parameters: - data – Mapping to validate.
- variant_index – Index number of the variant mapping if applicable. Default is None.
Raise: ValueErrorif the data mapping is incorrect.
-
wiz.validator.validate_version_keyword(data)[source]¶ Validate ‘version’ keyword within data mapping.
A correct data mapping should be in the form of:
{ "version": "0.1.0" }
Parameters: data – Mapping to validate. Raise: ValueErrorif the data mapping is incorrect.
-
wiz.validator.validate_namespace_keyword(data)[source]¶ Validate ‘namespace’ keyword within data mapping.
A correct data mapping should be in the form of:
{ "namespace": "foo" }
Parameters: data – Mapping to validate. Raise: ValueErrorif the data mapping is incorrect.
-
wiz.validator.validate_description_keyword(data)[source]¶ Validate ‘description’ keyword within data mapping.
A correct data mapping should be in the form of:
{ "description": "This is a description" }
Parameters: data – Mapping to validate. Raise: ValueErrorif the data mapping is incorrect.
-
wiz.validator.validate_auto_use_keyword(data)[source]¶ Validate ‘auto-use’ keyword within data mapping.
A correct data mapping should be in the form of:
{ "auto-use": true }
Parameters: data – Mapping to validate. Raise: ValueErrorif the data mapping is incorrect.
-
wiz.validator.validate_disabled_keyword(data)[source]¶ Validate ‘disabled’ keyword within data mapping.
A correct data mapping should be in the form of:
{ "disabled": true }
Parameters: data – Mapping to validate. Raise: ValueErrorif the data mapping is incorrect.
-
wiz.validator.validate_install_root_keyword(data)[source]¶ Validate ‘install-root’ keyword within data mapping.
A correct data mapping should be in the form of:
{ "install-root": "/path/to/install/root" }
Parameters: data – Mapping to validate. Raise: ValueErrorif the data mapping is incorrect.
-
wiz.validator.validate_install_location_keyword(data, variant_index=None)[source]¶ Validate ‘install-location’ keyword within data mapping.
A correct data mapping should be in the form of:
{ "install-location": "/path/to/install/location" }
Parameters: - data – Mapping to validate.
- variant_index – Index number of the variant mapping if applicable. Default is None.
Raise: ValueErrorif the data mapping is incorrect.
-
wiz.validator.validate_system_keyword(data)[source]¶ Validate ‘system’ keyword within data mapping.
A correct data mapping should be in the form of:
{ "system": { "platform": "linux" } }
Parameters: data – Mapping to validate. Raise: ValueErrorif the data mapping is incorrect.
-
wiz.validator.validate_command_keyword(data, variant_index=None)[source]¶ Validate ‘command’ keyword within data mapping.
A correct data mapping should be in the form of:
{ "command": { "foo": "FooExe" } }
Parameters: - data – Mapping to validate.
- variant_index – Index number of the variant mapping if applicable. Default is None.
Raise: ValueErrorif the data mapping is incorrect.
-
wiz.validator.validate_environ_keyword(data, variant_index=None)[source]¶ Validate ‘environ’ keyword within data mapping.
A correct data mapping should be in the form of:
{ "environ": { "KEY": "VALUE" } }
Parameters: - data – Mapping to validate.
- variant_index – Index number of the variant mapping if applicable. Default is None.
Raise: ValueErrorif the data mapping is incorrect.
-
wiz.validator.validate_requirements_keyword(data, variant_index=None)[source]¶ Validate ‘requirements’ keyword within data mapping.
A correct data mapping should be in the form of:
{ "requirements": [ "foo == 1.0.0", "bar >= 1, < 2" ] }
Parameters: - data – Mapping to validate.
- variant_index – Index number of the variant mapping if applicable. Default is None.
Raise: ValueErrorif the data mapping is incorrect.
-
wiz.validator.validate_conditions_keyword(data)[source]¶ Validate ‘conditions’ keyword within data mapping.
A correct data mapping should be in the form of:
{ "conditions": [ "bim >= 3.0.0" ] }
Parameters: data – Mapping to validate. Raise: ValueErrorif the data mapping is incorrect.
-
wiz.validator.validate_variants_keyword(data)[source]¶ Validate ‘variants’ keyword within data mapping.
A correct data mapping should be in the form of:
{ "variants": [ { "identifier": "foo", "install-location": "/path/to/install/location", "requirements": [ "bar >= 1, < 2" ] } ] }
Parameters: data – Mapping to validate. Raise: ValueErrorif the data mapping is incorrect.
-
wiz.validator.validate_keywords(data, keywords, label='Data')[source]¶ Ensure that no invalid keywords are in data mapping.
Parameters: - data – Mapping to validate.
- keywords – Set of authorized keywords.
- label – String to describe data if an error is raised. Default is “Data”.
Raise: ValueErrorif the data mapping is incorrect.
-
wiz.validator.validate_required(data, label='Data')[source]¶ Ensure that data exists.
Parameters: - data – Content to validate.
- label – String to describe data if an error is raised. Default is “Data”.
Raise: ValueErrorif data is incorrect.
-
wiz.validator.validate_type(data, data_type, label='Data')[source]¶ Ensure that data has correct type.
Parameters: - data – Content to validate.
- data_type – Type expected for data. It can be a tuple if several types are authorized.
- label – String to describe data if an error is raised. Default is “Data”.
Raise: ValueErrorif data is incorrect.
-
wiz.validator.validate_not_empty(data, label='Data')[source]¶ Ensure that data container is not empty.
Parameters: - data – Content to validate. It could be a list or a mapping.
- label – String to describe data if an error is raised. Default is “Data”.
Raise: ValueErrorif data is incorrect.