-
Notifications
You must be signed in to change notification settings - Fork 1
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
Testing search validation and unmarshal #29
Conversation
api/search.go
Outdated
@@ -3,8 +3,8 @@ package api | |||
// TODO: validation | |||
|
|||
type Attributes struct { | |||
Attributes []string `json:"attributes,omitempty"` | |||
ExcludedAttributes []string `json:"excludedAttributes,omitempty"` | |||
Attributes []string `json:"attributes,omitempty"` // TODO: validate Attribute Notation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use attrname
validator.
api/search.go
Outdated
Attributes []string `json:"attributes,omitempty"` | ||
ExcludedAttributes []string `json:"excludedAttributes,omitempty"` | ||
Attributes []string `json:"attributes,omitempty"` // TODO: validate Attribute Notation | ||
ExcludedAttributes []string `json:"excludedAttributes,omitempty"` // TODO: validate Attribute Notation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem with potatoes.
api/search.go
Outdated
@@ -3,8 +3,8 @@ package api | |||
// TODO: validation | |||
|
|||
type Attributes struct { | |||
Attributes []string `json:"attributes,omitempty"` // TODO: validate Attribute Notation | |||
ExcludedAttributes []string `json:"excludedAttributes,omitempty"` // TODO: validate Attribute Notation | |||
Attributes []string `json:"attributes,omitempty" validate:"attrname"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conceptually correct, thanks.
Anyway you should create a new custom validator - ie., attrpath
- and use it here ad per RFC 7644 attribute notation.
api/attr/path.go
Outdated
@@ -53,6 +55,14 @@ func Parse(s string) *Path { | |||
return a | |||
} | |||
|
|||
func (a Path) Valid() bool { | |||
s := a.Name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return len(a.Name) > 0
was too long?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leogr please use my style.
No description provided.