Skip to content

Commit

Permalink
Add replace operation it is alias for PUT http method (#9)
Browse files Browse the repository at this point in the history
* Add replace operation it is alias for PUT http method

* fix README.md
  • Loading branch information
Aliaksei Burau authored Dec 17, 2018
1 parent f127444 commit 5aae26e
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 97 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ gentool-options:
$(PROJECT_ROOT)/options/atlas_validate.proto

test: gentool-examples
go test ./example/examplepb
go test -v -cover ./example/examplepb
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ Field option:
message User {
//Field denied for create
int64 id = 1 [(atlas_validate.field).deny = create];
// Field denied for update and required for create
string name = 2 [(atlas_validate.field).deny = update, (atlas_validate.field).require = create];
//Field denied for create and update (ReadOnly access)
string email = 3 [(atlas_validate.field) = {deny: [create, update]}];
// Field denied for update and required for create and replace operations
string name = 2 [(atlas_validate.field).deny = update, (atlas_validate.field) = {require: [create, replace]}];
//Field denied for create, replace and update (ReadOnly access)
string email = 3 [(atlas_validate.field) = {deny: [create, replace, update]}];
}
```
### Generation
Expand Down
4 changes: 2 additions & 2 deletions example/examplepb/example.pb.atlas.validate.go

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

113 changes: 57 additions & 56 deletions example/examplepb/example.pb.go

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

8 changes: 4 additions & 4 deletions example/examplepb/example.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ option go_package = "github.com/infobloxopen/protoc-gen-atlas-validate/example/e

message User {
int32 id = 1 [(atlas_validate.field).deny = create];
string name = 2 [(atlas_validate.field) = {required: [create, update]}];
string name = 2 [(atlas_validate.field) = {required: [create, replace, update]}];
Profile profile = 3;
Address address = 4;
repeated Group groups = 5;
Expand All @@ -28,14 +28,14 @@ message User {

message Address {
string country = 1;
string state = 2 [(atlas_validate.field) = {deny:[update, create]}];
string state = 2 [(atlas_validate.field) = {deny:[update, replace, create]}];
string city = 3;
string zip = 4;
map<string,string> tags = 10;
}

message Group {
int32 id = 1 [(atlas_validate.field).required = update];
int32 id = 1 [(atlas_validate.field) = {required:[update, replace]}];
string name = 2 [(atlas_validate.field).required = create];
string notes = 3;
}
Expand Down Expand Up @@ -97,7 +97,7 @@ service Users {

message Profile {
int32 id = 1;
string name = 2 [(atlas_validate.field).deny = update];
string name = 2 [(atlas_validate.field) = {deny: [update, replace]}];
string notes = 3;
}

Expand Down
63 changes: 34 additions & 29 deletions options/atlas_validate.pb.go

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

3 changes: 3 additions & 0 deletions options/atlas_validate.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ message AtlasValidateFieldOption {

//Field allow only on update operation
update = 1;

//Field allow only on replace operation
replace = 2;
}

repeated Operation deny = 1;
Expand Down
Loading

1 comment on commit 5aae26e

@molon
Copy link

@molon molon commented on 5aae26e Dec 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What scenes need to be distinguished?
Maybe it's overdesign.

If must distinguish, create replace patch may be better.

Please sign in to comment.