Documentation
¶
Overview ¶
Package validate checks arguments against the contract before a request goes out.
This is the most direct payoff of reading OpenAPI rather than linking a generated SDK. In generated Go a field is just `Name string`; it does not know it is capped at 128 characters, and `DiskTypeId string` does not know it must be a UUID. Those constraints exist only in the contract.
$ leaflow compute disk create --name <129 chars> --size-gb 0
error: --name is longer than 128 characters (got 129)
--size-gb must be at least 1 (got 0)
The alternative is a 400 written for API callers, which does not contain the word "--size-gb" and has to be translated back to the flag by hand.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Error ¶
type Error struct {
Problems []string
// contains filtered or unexported fields
}
Error carries every problem at once. Reporting one at a time would make someone fix three mistakes in three round trips.
func NewError ¶ added in v0.59.2
NewError assembles a validation error from display problems and the details kept for debug logs.
func (*Error) DetailLines ¶ added in v0.59.2
DetailLines returns the diagnostic counterparts of Problems. When no details were collected, the problems themselves are all the diagnostics there are.
func (*Error) Diagnostic ¶ added in v0.59.1
Diagnostic returns the problems with the offending values included. It is for debug logs only: the values may be secrets and must never be rendered into a reply, an API error or anything else a user or model can read.