def validate_probabilities()

in src/braket/ir/jaqcd/shared_models.py [0:0]


    def validate_probabilities(cls, values):
        """
        Pydantic uses the validation subsystem to create objects. This custom validator has
        the purpose to ensure probX + probY + probZ <= 1.
        """
        p1, p2, p3 = values.get("probX"), values.get("probY"), values.get("probZ")
        if p1 + p2 + p3 > 1:
            raise ValueError("Sum of probabilities cannot exceed 1.")
        return values