Conditions | 4 |
Total Lines | 13 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | package validation_test |
||
22 | func (c NumericConstraint) ValidateString(value *string, scope validation.Scope) error { |
||
23 | // usually, you should ignore empty values |
||
24 | // to check for an empty value you should use it.NotBlankConstraint |
||
25 | if value == nil || *value == "" { |
||
26 | return nil |
||
27 | } |
||
28 | |||
29 | if c.matcher.MatchString(*value) { |
||
30 | return nil |
||
31 | } |
||
32 | |||
33 | // use the scope to build violation with translations |
||
34 | return scope.CreateViolation("notNumeric", "This value should be numeric.") |
||
35 | } |
||
49 |