Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加buf生态validator #44

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 97 additions & 80 deletions blog/api/blog/v1/blog.pb.go

Large diffs are not rendered by default.

13 changes: 2 additions & 11 deletions blog/api/blog/v1/blog.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion blog/api/blog/v1/blog.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ option go_package = "github.com/go-kratos/examples/blog/api/blog/v1;v1";

import "google/api/annotations.proto";
import "validate/validate.proto";
import "buf/validate/validate.proto"; // buf生态validate

service BlogService {
rpc CreateArticle (CreateArticleRequest) returns (CreateArticleReply) {
Expand Down Expand Up @@ -45,7 +46,12 @@ message Article {
}

message CreateArticleRequest {
string title = 1 [(validate.rules).string = {min_len: 5, max_len: 50}]; // the title of string must be between 5 and 50 character
// doc: https://github.com/bufbuild/protovalidate
string title = 1 [json_name = "title", (buf.validate.field).cel = {
id: "CreateArticleRequest.title",
message: "the title of string must be between 5 and 50 character",
expression: "size(this) > 5 && size(this) <= 50",
}]; // the title of string must be between 5 and 50 character
string content = 2;
}

Expand Down
32 changes: 20 additions & 12 deletions blog/api/blog/v1/blog_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 13 additions & 7 deletions blog/api/blog/v1/blog_http.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions blog/api/blog/v1/error.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blog/api/blog/v1/error.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blog/api/blog/v1/error_errors.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions blog/api/buf.lock
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: bufbuild
repository: protovalidate
commit: f05a6f4403ce4327bae4f50f281c3ed0
digest: shake256:668a0661b8df44d41839194896329330965fc215f3d2f88057fd60eeb759c2daf6cc6edfdd13b2a653d49fe2896ebedcb1a33c4c5b2dd10919f03ffb7fc52ae6
- remote: buf.build
owner: envoyproxy
repository: protoc-gen-validate
commit: 6607b10f00ed4a3d98f906807131c44a
commit: 71881f09a0c5420a9545a07987a86728
digest: shake256:d320bbf06653b1b2b45a1f95bfa82bf7b998221a777a042708c50d6f86a30d1a85b50c5704c597142d9b308280efe1295d39d76d1abea5f7046d3df4c8cc3cef
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 75b4300737fb4efca0831636be94e517
commit: 7e6f6e774e29406da95bd61cdcdbc8bc
digest: shake256:fe43dd2265ea0c07d76bd925eeba612667cf4c948d2ce53d6e367e1b4b3cb5fa69a51e6acb1a6a50d32f894f054a35e6c0406f6808a483f2752e10c866ffbf73
- remote: buf.build
owner: kratos
repository: apis
commit: c2de25f14fa445a79a054214f31d17a8
digest: shake256:91c024935d46f7966667c29e4fc933435959f93c3f0e675e1227c99db09905d44f8ec275b770da7659df5a6b18f4710da157b6d8ad760a4a95f60365b231e637
15 changes: 8 additions & 7 deletions blog/api/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
version: v1
breaking:
use:
- FILE
use:
- FILE
deps:
- buf.build/googleapis/googleapis
- buf.build/envoyproxy/protoc-gen-validate
- buf.build/kratos/apis
- buf.build/googleapis/googleapis
- buf.build/envoyproxy/protoc-gen-validate
- buf.build/kratos/apis
- buf.build/bufbuild/protovalidate
lint:
use:
- DEFAULT
use:
- DEFAULT
Loading