本文整理匯總了Golang中github.com/markbates/going/validate.Errors.Add方法的典型用法代碼示例。如果您正苦於以下問題:Golang Errors.Add方法的具體用法?Golang Errors.Add怎麽用?Golang Errors.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/markbates/going/validate.Errors
的用法示例。
在下文中一共展示了Errors.Add方法的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))
}
}