{"modulePath":"github.com/LeaflowNET/leaflow","version":"v0.59.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package validate\n\nPackage validate checks arguments against the contract before a request goes out.\n\nThis 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.\n\n\t$ leaflow compute disk create --name \u003c129 chars\u003e --size-gb 0\n\terror: --name is longer than 128 characters (got 129)\n\t       --size-gb must be at least 1 (got 0)\n\nThe 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.\n\n## Functions\n\n```go\nfunc Value(schema *openapi3.Schema, value any, label Labeler) error\n```\n\n## Types\n\n```go\ntype Error struct {\n\tProblems []string\n\t// contains filtered or unexported fields\n}\n```\nError carries every problem at once. Reporting one at a time would make someone fix three mistakes in three round trips.\n\n```go\nfunc NewError(problems, details []string) *Error\n```\nNewError assembles a validation error from display problems and the details kept for debug logs.\n\n```go\nfunc (e *Error) DetailLines() []string\n```\nDetailLines returns the diagnostic counterparts of Problems. When no details were collected, the problems themselves are all the diagnostics there are.\n\n```go\nfunc (e *Error) Diagnostic() string\n```\nDiagnostic 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.\n\n```go\nfunc (e *Error) Error() string\n```\n\n```go\nfunc (e *Error) Unwrap() error\n```\nUnwrap places a validation failure among the transport's kinds, so that one question — \"were the arguments wrong?\" — has one answer whether the contract caught it here or the service caught it there.\n\n```go\ntype Labeler func(path []string) string\n```\nLabeler translates a JSON field path into the name the user typed. The validator knows \\`/size\\_gb\\`; the user typed \\`--size-gb\\`.\n\n","path":"github.com/LeaflowNET/leaflow/pkg/validate","name":"validate","synopsis":"Package validate checks arguments against the contract before a request goes out.","isRedistributable":true}
