@bufbuild/protovalidate
Version:
Protocol Buffer Validation for ECMAScript
52 lines (51 loc) • 4.32 kB
TypeScript
import { type DescMessage, ScalarType } from "@bufbuild/protobuf";
import type { PathBuilder } from "@bufbuild/protobuf/reflect";
import { type FieldRules } from "./gen/buf/validate/validate_pb.js";
/**
* Get the ScalarType for one of the buf.validate.*Rules messages.
*/
export declare function getRuleScalarType(rule: Exclude<FieldRules["type"]["value"], undefined>): ScalarType | undefined;
/**
* Get the descriptor for one of the buf.validate.*Rules messages.
*/
export declare function getRuleDescriptor(typeName: Exclude<FieldRules["type"]["value"], undefined>["$typeName"]): DescMessage;
/**
* Get buf.validate.RepeatedRules from FieldRules.
* Returns a tuple with rules, and path to the rules.
* Throws an error if the FieldRules has incompatible rules.
*/
export declare function getListRules(rulePath: PathBuilder, fieldRules: FieldRules | undefined, fieldContext: {
toString(): string;
}): readonly [import("./gen/buf/validate/validate_pb.js").RepeatedRules | undefined, PathBuilder, PathBuilder];
/**
* Get buf.validate.MapRules from FieldRules.
* Returns a tuple with rules, and path to the rules.
* Throws an error if the FieldRules has incompatible rules.
*/
export declare function getMapRules(rulePath: PathBuilder, fieldRules: FieldRules | undefined, fieldContext: {
toString(): string;
}): readonly [import("./gen/buf/validate/validate_pb.js").MapRules | undefined, PathBuilder, PathBuilder, PathBuilder];
/**
* Get buf.validate.EnumRules from FieldRules.
* Returns a tuple with rules, and path to the rules.
* Throws an error if the FieldRules has incompatible rules.
*/
export declare function getEnumRules(rulePath: PathBuilder, fieldRules: FieldRules | undefined, fieldContext: {
toString(): string;
}): readonly [import("./gen/buf/validate/validate_pb.js").EnumRules | undefined, PathBuilder];
/**
* Get buf.validate.*Rules for the given message type from FieldRules.
* Returns a tuple with rules, and path to the rules.
* Throws an error if the FieldRules has incompatible rules.
*/
export declare function getMessageRules(descMessage: DescMessage, rulePath: PathBuilder, fieldRules: FieldRules | undefined, fieldContext: {
toString(): string;
}): readonly [import("./gen/buf/validate/validate_pb.js").FloatRules | import("./gen/buf/validate/validate_pb.js").DoubleRules | import("./gen/buf/validate/validate_pb.js").Int32Rules | import("./gen/buf/validate/validate_pb.js").Int64Rules | import("./gen/buf/validate/validate_pb.js").UInt32Rules | import("./gen/buf/validate/validate_pb.js").UInt64Rules | import("./gen/buf/validate/validate_pb.js").SInt32Rules | import("./gen/buf/validate/validate_pb.js").BoolRules | import("./gen/buf/validate/validate_pb.js").StringRules | import("./gen/buf/validate/validate_pb.js").BytesRules | import("./gen/buf/validate/validate_pb.js").AnyRules | import("./gen/buf/validate/validate_pb.js").DurationRules | import("./gen/buf/validate/validate_pb.js").FieldMaskRules | import("./gen/buf/validate/validate_pb.js").TimestampRules | undefined, PathBuilder];
/**
* Get buf.validate.*Rules for the given scalar type from FieldRules.
* Returns a tuple with rules, and path to the rules.
* Throws an error if the FieldRules has incompatible rules.
*/
export declare function getScalarRules(scalar: ScalarType, rulePath: PathBuilder, fieldRules: FieldRules | undefined, fieldContext: {
toString(): string;
}): readonly [import("./gen/buf/validate/validate_pb.js").FloatRules | import("./gen/buf/validate/validate_pb.js").DoubleRules | import("./gen/buf/validate/validate_pb.js").Int32Rules | import("./gen/buf/validate/validate_pb.js").Int64Rules | import("./gen/buf/validate/validate_pb.js").UInt32Rules | import("./gen/buf/validate/validate_pb.js").UInt64Rules | import("./gen/buf/validate/validate_pb.js").SInt32Rules | import("./gen/buf/validate/validate_pb.js").SInt64Rules | import("./gen/buf/validate/validate_pb.js").Fixed32Rules | import("./gen/buf/validate/validate_pb.js").Fixed64Rules | import("./gen/buf/validate/validate_pb.js").SFixed32Rules | import("./gen/buf/validate/validate_pb.js").SFixed64Rules | import("./gen/buf/validate/validate_pb.js").BoolRules | import("./gen/buf/validate/validate_pb.js").StringRules | import("./gen/buf/validate/validate_pb.js").BytesRules | undefined, PathBuilder];