@nebius/js-sdk - v0.2.54
    Preparing search index...

    Interface Violation

    Violation represents a single instance where a validation rule, expressed as a Rule, was not met. It provides information about the field that caused the violation, the specific rule that wasn't fulfilled, and a human-readable error message.

    For example, consider the following message:

    message User {
    int32 age = 1 [(buf.validate.field).cel = {
    id: "user.age",
    expression: "this < 18 ? 'User must be at least 18 years old' : ''",
    }];
    }

    It could produce the following violation:

    {
    "ruleId": "user.age",
    "message": "User must be at least 18 years old",
    "field": {
    "elements": [
    {
    "fieldNumber": 1,
    "fieldName": "age",
    "fieldType": "TYPE_INT32"
    }
    ]
    },
    "rule": {
    "elements": [
    {
    "fieldNumber": 23,
    "fieldName": "cel",
    "fieldType": "TYPE_MESSAGE",
    "index": "0"
    }
    ]
    }
    }
    interface Violation {
        "[customJson]"?: () => unknown;
        "[unknownFieldsSymbol]"?: Uint8Array<ArrayBufferLike>;
        $type: "buf.validate.Violation";
        field?: FieldPath;
        forKey?: boolean;
        message?: string;
        rule?: FieldPath;
        ruleId?: string;
        [key: symbol]: Uint8Array<ArrayBufferLike> | (() => unknown) | undefined;
    }

    Indexable

    • [key: symbol]: Uint8Array<ArrayBufferLike> | (() => unknown) | undefined

      Violation represents a single instance where a validation rule, expressed as a Rule, was not met. It provides information about the field that caused the violation, the specific rule that wasn't fulfilled, and a human-readable error message.

      For example, consider the following message:

      message User {
      int32 age = 1 [(buf.validate.field).cel = {
      id: "user.age",
      expression: "this < 18 ? 'User must be at least 18 years old' : ''",
      }];
      }

      It could produce the following violation:

      {
      "ruleId": "user.age",
      "message": "User must be at least 18 years old",
      "field": {
      "elements": [
      {
      "fieldNumber": 1,
      "fieldName": "age",
      "fieldType": "TYPE_INT32"
      }
      ]
      },
      "rule": {
      "elements": [
      {
      "fieldNumber": 23,
      "fieldName": "cel",
      "fieldType": "TYPE_MESSAGE",
      "index": "0"
      }
      ]
      }
      }
      • Uint8Array<ArrayBufferLike>
      • () => unknown
          • (): unknown
          • Violation represents a single instance where a validation rule, expressed as a Rule, was not met. It provides information about the field that caused the violation, the specific rule that wasn't fulfilled, and a human-readable error message.

            For example, consider the following message:

            message User {
            int32 age = 1 [(buf.validate.field).cel = {
            id: "user.age",
            expression: "this < 18 ? 'User must be at least 18 years old' : ''",
            }];
            }

            It could produce the following violation:

            {
            "ruleId": "user.age",
            "message": "User must be at least 18 years old",
            "field": {
            "elements": [
            {
            "fieldNumber": 1,
            "fieldName": "age",
            "fieldType": "TYPE_INT32"
            }
            ]
            },
            "rule": {
            "elements": [
            {
            "fieldNumber": 23,
            "fieldName": "cel",
            "fieldType": "TYPE_MESSAGE",
            "index": "0"
            }
            ]
            }
            }

            Returns unknown

      • undefined
    Index
    "[customJson]"?: () => unknown

    Returns a safe value for JSON logs.

    Type Declaration

      • (): unknown
      • Returns a safe value for JSON logs.

        Returns unknown

    "[unknownFieldsSymbol]"?: Uint8Array<ArrayBufferLike>

    Preserves protobuf fields that this SDK version does not recognize.

    $type: "buf.validate.Violation"

    Contains the fully qualified protobuf type name.

    field?: FieldPath

    field is a machine-readable path to the field that failed validation. This could be a nested field, in which case the path will include all the parent fields leading to the actual field that caused the violation.

    For example, consider the following message:

    message Message {
    bool a = 1 [(buf.validate.field).required = true];
    }

    It could produce the following violation:

    violation {
      field { element { field_number: 1, field_name: "a", field_type: 8 } }
      ...
    }
    
    forKey?: boolean

    for_key indicates whether the violation was caused by a map key, rather than a value.

    message?: string

    message is a human-readable error message that describes the nature of the violation. This can be the default error message from the violated Rule, or it can be a custom message that gives more context about the violation.

    rule?: FieldPath

    rule is a machine-readable path that points to the specific rule that failed validation. This will be a nested field starting from the FieldRules of the field that failed validation. For custom rules, this will provide the path of the rule, e.g. cel[0].

    For example, consider the following message:

    message Message {
    bool a = 1 [(buf.validate.field).required = true];
    bool b = 2 [(buf.validate.field).cel = {
    id: "custom_rule",
    expression: "!this ? 'b must be true': ''"
    }]
    }

    It could produce the following violations:

    violation {
      rule { element { field_number: 25, field_name: "required", field_type: 8 } }
      ...
    }
    violation {
      rule { element { field_number: 23, field_name: "cel", field_type: 11, index: 0 } }
      ...
    }
    
    ruleId?: string

    rule_id is the unique identifier of the Rule that was not fulfilled. This is the same id that was specified in the Rule message, allowing easy tracing of which rule was violated.