-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Implement bottom up validation #398
Conversation
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.
LGTM, great work!
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.
lgtm, just small nits
cmd/config.go
Outdated
if err = c.ValidatePathEnd(p.Src); err != nil { | ||
return err | ||
} | ||
if p.Src.Version == "" { | ||
return fmt.Errorf("source must specify a version") | ||
} |
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.
Let's re-order this check
if err = c.ValidatePathEnd(p.Src); err != nil { | |
return err | |
} | |
if p.Src.Version == "" { | |
return fmt.Errorf("source must specify a version") | |
} | |
if p.Src.Version == "" { | |
return fmt.Errorf("source must specify a version") | |
} | |
if err = c.ValidatePathEnd(p.Src); err != nil { | |
return err | |
} |
cmd/config.go
Outdated
if pe.ClientID != "" { | ||
if err := c.ValidateClient(chain, height, pe); err != nil { | ||
return err | ||
} | ||
} | ||
if pe.ConnectionID != "" { | ||
if err := c.ValidateConnection(chain, height, pe); err != nil { | ||
return err | ||
} | ||
} | ||
if pe.ChannelID != "" { | ||
if err := c.ValidateChannel(chain, height, pe); err != nil { | ||
return err | ||
} | ||
} |
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.
I think if the ClientID
is nil, there's no point in validating connection or channel details. We can just return err
if the ClientID is nil and connectionID is not nil. Similarly for ChannelID
if pe.ClientID != "" { | |
if err := c.ValidateClient(chain, height, pe); err != nil { | |
return err | |
} | |
} | |
if pe.ConnectionID != "" { | |
if err := c.ValidateConnection(chain, height, pe); err != nil { | |
return err | |
} | |
} | |
if pe.ChannelID != "" { | |
if err := c.ValidateChannel(chain, height, pe); err != nil { | |
return err | |
} | |
} | |
if pe.ClientID != "" { | |
if err := c.ValidateClient(chain, height, pe); err != nil { | |
return err | |
} | |
if pe.ConnectionID != "" { | |
if err := c.ValidateConnection(chain, height, pe); err != nil { | |
return err | |
} | |
if pe.ChannelID != "" { | |
if err := c.ValidateChannel(chain, height, pe); err != nil { | |
return err | |
} | |
} | |
} | |
} | |
if pe.ClientID == "" && pe.ConnectionID != "" { | |
return fmt.Errorf("ClientID is not conifgured for the connection: %s", pe.ConnectionID) | |
} |
Fixes: #345