# This file was auto-generated by Fern from our API Definition.

import typing

from ..core import enum

T_Result = typing.TypeVar("T_Result")


class RuleValidationResultRulesItemFailureReason(enum.StrEnum):
    """
    If the validation rule is not valid, then this describes why the rule failed.
    * `"RULE_FAILED"` - The formula evaluated to `false` or `null`
    * `"PARSE_ERROR"` - The formula could not be parsed
    * `"VALUE_ERROR"` - An error occurred while evaluating the formula
    """

    RULE_FAILED = "RULE_FAILED"
    PARSE_ERROR = "PARSE_ERROR"
    VALUE_ERROR = "VALUE_ERROR"
    _UNKNOWN = "__RULEVALIDATIONRESULTRULESITEMFAILUREREASON_UNKNOWN__"
    """
    This member is used for forward compatibility. If the value is not recognized by the enum, it will be stored here, and the raw value is accessible through `.value`.
    """

    @classmethod
    def _missing_(cls, value: typing.Any) -> "RuleValidationResultRulesItemFailureReason":
        unknown = cls._UNKNOWN
        unknown._value_ = value
        return unknown

    def visit(
        self,
        rule_failed: typing.Callable[[], T_Result],
        parse_error: typing.Callable[[], T_Result],
        value_error: typing.Callable[[], T_Result],
        _unknown_member: typing.Callable[[str], T_Result],
    ) -> T_Result:
        if self is RuleValidationResultRulesItemFailureReason.RULE_FAILED:
            return rule_failed()
        if self is RuleValidationResultRulesItemFailureReason.PARSE_ERROR:
            return parse_error()
        if self is RuleValidationResultRulesItemFailureReason.VALUE_ERROR:
            return value_error()
        return _unknown_member(self._value_)
