本文整理匯總了Golang中github.com/markbates/going/validate.Errors類的典型用法代碼示例。如果您正苦於以下問題:Golang Errors類的具體用法?Golang Errors怎麽用?Golang Errors使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Errors類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: IsValid
func (v *StringInclusion) IsValid(errors *validate.Errors) {
found := false
for _, l := range v.List {
if l == v.Field {
found = true
break
}
}
if !found {
errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s is not in the list [%s].", v.Name, strings.Join(v.List, ", ")))
}
}
示例2: IsValid
func (v *IntIsPresent) IsValid(errors *validate.Errors) {
if v.Field == 0 {
errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be blank.", v.Name))
}
}
示例3: IsValid
func (v *TimeIsBeforeTime) IsValid(errors *validate.Errors) {
if v.FirstTime.UnixNano() > v.SecondTime.UnixNano() {
errors.Add(GenerateKey(v.FirstName), fmt.Sprintf("%s must be before %s.", v.FirstName, v.SecondName))
}
}
示例4: IsValid
func (v *BytesArePresent) IsValid(errors *validate.Errors) {
if len(v.Field) == 0 {
errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be blank.", v.Name))
}
}
示例5: IsValid
func (v *TimeIsPresent) IsValid(errors *validate.Errors) {
t := time.Time{}
if v.Field.UnixNano() == t.UnixNano() {
errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be blank.", v.Name))
}
}
示例6: IsValid
func (f *FuncValidator) IsValid(verrs *validate.Errors) {
if !f.Fn() {
verrs.Add(GenerateKey(f.Field), fmt.Sprintf(f.Message, f.Field))
}
}
示例7: IsValid
func (v *IntArrayIsPresent) IsValid(errors *validate.Errors) {
if len(v.Field) == 0 {
errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be empty.", v.Name))
}
}