Skip to content

duplicates_validator

trestle.core.duplicates_validator ¤

Validate by confirming no duplicate uuids.

Classes¤

DuplicatesValidator (Validator) ¤

Validator to check for duplicate uuids and param_ids in the model.

Source code in trestle/core/duplicates_validator.py
class DuplicatesValidator(Validator):
    """Validator to check for duplicate uuids and param_ids in the model."""

    def model_is_valid(self, model: OscalBaseModel, quiet: bool) -> bool:
        """
        Test if the model is valid and contains no duplicate uuids or param_ids.

        args:
            model: An Oscal model that can be passed to the validator.
            quiet: Don't report msgs unless invalid.

        returns:
            True (valid) if the model does not contain duplicate uuid's.
        """
        if not ModelUtils.has_no_duplicate_values_by_name(model, 'uuid'):
            return False
        return ModelUtils.has_no_duplicate_values_by_name(model, 'param_id')
Methods¤
model_is_valid(self, model, quiet) ¤

Test if the model is valid and contains no duplicate uuids or param_ids.

Parameters:

Name Type Description Default
model OscalBaseModel

An Oscal model that can be passed to the validator.

required
quiet bool

Don't report msgs unless invalid.

required

Returns:

Type Description
bool

True (valid) if the model does not contain duplicate uuid's.

Source code in trestle/core/duplicates_validator.py
def model_is_valid(self, model: OscalBaseModel, quiet: bool) -> bool:
    """
    Test if the model is valid and contains no duplicate uuids or param_ids.

    args:
        model: An Oscal model that can be passed to the validator.
        quiet: Don't report msgs unless invalid.

    returns:
        True (valid) if the model does not contain duplicate uuid's.
    """
    if not ModelUtils.has_no_duplicate_values_by_name(model, 'uuid'):
        return False
    return ModelUtils.has_no_duplicate_values_by_name(model, 'param_id')

handler: python