DBDelve
Dive deep into your data. A fast, native, multi-engine database client written in Rust. Free and open source, no telemetry.
翻譯準備中
:100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving
翻譯準備中
開發工具Go · MakefileGitHub @go-playground自行安裝營運者未確認
試用過了嗎? 點一下就好,不需要登入。
製作者的介紹僅有上面的一句話。 更多詳情請閱讀儲存庫 README。 儲存庫 README ↗
正在載入完整 README。
檢視完整 README ↗Package validator implements value validations for structs and individual fields based on tags.
It has the following unique features:
Please read the discussion started here if you are interested in contributing/helping maintain this package.
Use go get.
go get github.com/go-playground/validator/v10
Then import the validator package into your own code.
import "github.com/go-playground/validator/v10"
Validation functions return type error
They return type error to avoid the issue discussed in the following, where err is always != nil:
Validator returns only InvalidValidationError for bad validation input, nil or ValidationErrors as type error; so, in your code all you need to do is check if the error returned is not nil, and if it's not check if error is InvalidValidationError ( if necessary, most of the time it isn't ) type cast it to type ValidationErrors like so:
err := validate.Struct(mystruct)
var validationErrors validator.ValidationErrors
errors.As(err, &validationErrors)
Please see https://pkg.go.dev/github.com/go-playground/validator/v10 for detailed usage docs.
WithRequiredStructEnabled option which is opt-in to new behaviour that will become the default behaviour in v11+. See documentation for more details.validate := validator.New(validator.WithRequiredStructEnabled())
| Tag | Description |
|---|---|
| eqcsfield | Field Equals Another Field (relative) |
| eqfield | Field Equals Another Field |
| fieldcontains | Check the indicated characters are present in the Field |
| fieldexcludes | Current field does not contain another field's value |
| gtcsfield | Field Greater Than Another Relative Field |
| gtecsfield | Field Greater Than or Equal To Another Relative Field |
| gtefield | Field Greater Than or Equal To Another Field |
| gtfield | Field Greater Than Another Field |
| ltcsfield | Less Than Another Relative Field |
| ltecsfield | Less Than or Equal To Another Relative Field |
| ltefield | Less Than or Equal To Another Field |
| ltfield | Less Than Another Field |
| necsfield | Field Does Not Equal Another Field (relative) |
| nefield | Field Does Not Equal Another Field |
以上為 README 的開頭部分。其餘內容請閱讀原文。 檢視完整 README ↗