crunk1

crunk1

Member Since 9 years ago

Experience Points
2
follower
Lessons Completed
7
follow
Lessons Completed
41
stars
Best Reply Awards
12
repos

3 contributions in the last year

Pinned
⚡ An analysis of Book of Mormon content and changes.
⚡ A Go hodge-podge, swiss army knife.
⚡ A CLI tool for adding, managing, and viewing your own cheatsheets.
⚡ Implementations of https://datatracker.ietf.org/doc/draft-ietf-httpbis-message-signatures/
Activity
Jan
13
6 days ago
pull request

crunk1 pull request json-iterator/go

crunk1
crunk1

Return first field encoding error encountered, if any, when encoding a struct.

Addresses #472

pull request

crunk1 pull request zalando/connexion

crunk1
crunk1

Add for support relative paths in schema refs -- updated.

Refs #461 Refs #254 Updates #543

From #543: "Fix to allow the json schema validation to handle relative refs by passing in the spec file path. This will only work when passing a file path to add_api and not a dict. Note: This will only work with response validation disabled. There are more changes required to support local refs elsewhere in the code."

pull request

crunk1 pull request MongoEngine/mongoengine

crunk1
crunk1

Add ObjectIdMapField.

Adds a MapField that can be indexed by ObjectId-like objects.

Nov
24
1 month ago
Nov
23
1 month ago
Activity icon
created branch
createdAt 1 month ago
push

crunk1 push novohealth/deploy-sourcegraph-docker

crunk1
crunk1

fix(deps): update github.com/sourcegraph/sourcegraph/enterprise/dev/ci/images commit hash to c30e188 (#637)

Co-authored-by: Renovate Bot [email protected]

commit sha: c2533e438bf7d1f132d638371dab573a216416d4

push time in 1 month ago
Oct
26
2 months ago
started
started time in 2 months ago
Oct
20
2 months ago
started
started time in 2 months ago
Activity icon
issue

crunk1 issue envoyproxy/protoc-gen-validate

crunk1
crunk1

v0.5.0 Go code generation broken when using map.keys.string.in

Hi all!

I'm using thethingsindustries/protoc, so it's not super easy for me to test newer versions of PGV. Forgive me if this is already fixed. When using map.keys.string.in, the generated code results in a reference to an undefined function.

Consider this snippet from my proto:

message SetOrgDefaultAlertRulesReq {
  map<string, AlertRule> alertRules = 1 [(validate.rules).map.keys.string = { in: ["foo"] }];
}

The resulting pb.validate.go:

// Validate checks the field values on SetOrgDefaultAlertRulesReq with the
// rules defined in the proto definition for this message. If any rules are
// violated, an error is returned.
func (m *SetOrgDefaultAlertRulesReq) Validate() error {
	if m == nil {
		return nil
	}

	for key, val := range m.GetAlertRules() {
		_ = val

		if _, ok := _SetOrgDefaultAlertRulesReq_AlertRules_InLookup[key]; !ok {
			return SetOrgDefaultAlertRulesReqValidationError{
				field:  fmt.Sprintf("AlertRules[%v]", key),
				reason: "value must be in list [foo]",
			}
		}

		if v, ok := interface{}(val).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return SetOrgDefaultAlertRulesReqValidationError{
					field:  fmt.Sprintf("AlertRules[%v]", key),
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

	return nil
}

The function _SetOrgDefaultAlertRulesReq_AlertRules_InLookup does not get generated.

Also, is the validation error reason "value must be in list [foo]" correct? Should it be "key must be in list [foo]"? I can understand that the value of the key is being checked, but the word value seems a bit overloaded in a map context.

Thanks in advance!