(val []bool, v *BoolListValidation)
| 85 | } |
| 86 | |
| 87 | func validateBoolList(val []bool, v *BoolListValidation) ([]bool, error) { |
| 88 | if !v.AllowEmpty { |
| 89 | if val != nil && len(val) == 0 { |
| 90 | return nil, ErrorCannotBeEmpty() |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | if v.MinLength != 0 { |
| 95 | if len(val) < v.MinLength { |
| 96 | return nil, ErrorTooFewElements(v.MinLength) |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | if v.MaxLength != 0 { |
| 101 | if len(val) > v.MaxLength { |
| 102 | return nil, ErrorTooManyElements(v.MaxLength) |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | for _, invalidLength := range v.InvalidLengths { |
| 107 | if len(val) == invalidLength { |
| 108 | return nil, ErrorWrongNumberOfElements(v.InvalidLengths) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | if v.Validator != nil { |
| 113 | return v.Validator(val) |
| 114 | } |
| 115 | return val, nil |
| 116 | } |
no test coverage detected