diff options
author | Daniil Baturin <daniil@baturin.org> | 2015-04-26 15:01:13 +0600 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2015-04-26 15:01:13 +0600 |
commit | 35bbd44f54b2738027869d67c99f55c742945a5e (patch) | |
tree | 97639859ac8b7004927ad33c4d9090845f0029ad /src | |
parent | 124b2b2e1081e45bfd31bb71992f9b60550e6668 (diff) | |
download | vyconf-35bbd44f54b2738027869d67c99f55c742945a5e.tar.gz vyconf-35bbd44f54b2738027869d67c99f55c742945a5e.zip |
Make Value_checker.validate_any return true if constraint list is empty
(i.e. no constraints means anything goes).
Diffstat (limited to 'src')
-rw-r--r-- | src/value_checker.ml | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/value_checker.ml b/src/value_checker.ml index 245b769..1c19c3d 100644 --- a/src/value_checker.ml +++ b/src/value_checker.ml @@ -17,8 +17,16 @@ let validate_value validators value_constraint value = | _ -> false with Not_found -> raise (Bad_validator t) -let rec validate_any validators constraints value = +(* If no constraints given, consider it valid. + Otherwise consider it valid if it satisfies at least + one constraint *) +let validate_any validators constraints value = + let rec aux validators constraints value = + match constraints with + | [] -> false + | c :: cs -> if validate_value validators c value then true + else aux validators cs value + in match constraints with - | [] -> false - | c :: cs -> if validate_value validators c value then true - else validate_any validators cs value + | [] -> true + | _ -> aux validators constraints value |