Skip to content

Commit 41c8d85

Browse files
authored
Merge pull request revel#1114 from torden/feature/add-validation
Improve Validation API
2 parents caf6730 + a78ac94 commit 41c8d85

File tree

3 files changed

+764
-1
lines changed

3 files changed

+764
-1
lines changed

validation.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,30 @@ func (v *Validation) Email(str string) *ValidationResult {
139139
return v.apply(Email{Match{emailPattern}}, str)
140140
}
141141

142+
func (v *Validation) IPAddr(str string, cktype ...int) *ValidationResult {
143+
return v.apply(IPAddr{cktype}, str)
144+
}
145+
146+
func (v *Validation) MacAddr(str string) *ValidationResult {
147+
return v.apply(IPAddr{}, str)
148+
}
149+
150+
func (v *Validation) Domain(str string) *ValidationResult {
151+
return v.apply(Domain{}, str)
152+
}
153+
154+
func (v *Validation) URL(str string) *ValidationResult {
155+
return v.apply(URL{}, str)
156+
}
157+
158+
func (v *Validation) PureText(str string, m int) *ValidationResult {
159+
return v.apply(PureText{m}, str)
160+
}
161+
162+
func (v *Validation) FilePath(str string, m int) *ValidationResult {
163+
return v.apply(FilePath{m}, str)
164+
}
165+
142166
func (v *Validation) apply(chk Validator, obj interface{}) *ValidationResult {
143167
if chk.IsSatisfied(obj) {
144168
return &ValidationResult{Ok: true}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy