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

    Interface MessageRules

    MessageRules represents validation rules that are applied to the entire message. It includes disabling options and a list of Rule messages representing Common Expression Language (CEL) validation rules.

    interface MessageRules {
        "[customJson]"?: () => unknown;
        "[unknownFieldsSymbol]"?: Uint8Array<ArrayBufferLike>;
        $type: "buf.validate.MessageRules";
        cel: Rule[];
        celExpression: string[];
        oneof: MessageOneofRule[];
        [key: symbol]: Uint8Array<ArrayBufferLike> | (() => unknown) | undefined;
    }

    Indexable

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

      MessageRules represents validation rules that are applied to the entire message. It includes disabling options and a list of Rule messages representing Common Expression Language (CEL) validation rules.

      • Uint8Array<ArrayBufferLike>
      • () => unknown
          • (): unknown
          • MessageRules represents validation rules that are applied to the entire message. It includes disabling options and a list of Rule messages representing Common Expression Language (CEL) validation rules.

            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.MessageRules"

    Contains the fully qualified protobuf type name.

    cel: Rule[]

    cel is a repeated field of type Rule. Each Rule specifies a validation rule to be applied to this message. These rules are written in Common Expression Language (CEL) syntax. For more information, see our documentation.

    message MyMessage {
    // The field `foo` must be greater than 42.
    option (buf.validate.message).cel = {
    id: "my_message.value",
    message: "value must be greater than 42",
    expression: "this.foo > 42",
    };
    optional int32 foo = 1;
    }
    celExpression: string[]

    cel_expression is a repeated field CEL expressions. Each expression specifies a validation rule to be applied to this message. These rules are written in Common Expression Language (CEL) syntax.

    This is a simplified form of the cel Rule field, where only expression is set. This allows for simpler syntax when defining CEL Rules where id and message derived from the expression. id will be same as the expression.

    For more information, see our documentation.

    message MyMessage {
    // The field `foo` must be greater than 42.
    option (buf.validate.message).cel_expression = "this.foo > 42";
    // The field `foo` must be less than 84.
    option (buf.validate.message).cel_expression = "this.foo < 84";
    optional int32 foo = 1;
    }

    oneof is a repeated field of type MessageOneofRule that specifies a list of fields of which at most one can be present. If required is also specified, then exactly one of the specified fields must be present.

    This will enforce oneof-like constraints with a few features not provided by actual Protobuf oneof declarations:

    1. Repeated and map fields are allowed in this validation. In a Protobuf oneof, only scalar fields are allowed.
    2. Fields with implicit presence are allowed. In a Protobuf oneof, all member fields have explicit presence. This means that, for the purpose of determining how many fields are set, explicitly setting such a field to its zero value is effectively the same as not setting it at all.
    3. This will always generate validation errors for a message unmarshalled from serialized data that sets more than one field. With a Protobuf oneof, when multiple fields are present in the serialized form, earlier values are usually silently ignored when unmarshalling, with only the last field being set when unmarshalling completes.

    Note that adding a field to a oneof will also set the IGNORE_IF_ZERO_VALUE on the fields. This means only the field that is set will be validated and the unset fields are not validated according to the field rules. This behavior can be overridden by setting ignore against a field.

    message MyMessage {
    // Only one of `field1` or `field2` _can_ be present in this message.
    option (buf.validate.message).oneof = { fields: ["field1", "field2"] };
    // Exactly one of `field3` or `field4` _must_ be present in this message.
    option (buf.validate.message).oneof = { fields: ["field3", "field4"], required: true };
    string field1 = 1;
    bytes field2 = 2;
    bool field3 = 3;
    int32 field4 = 4;
    }