diff options
author | Daniil Baturin <daniil@baturin.org> | 2015-04-24 21:52:18 +0600 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2015-04-24 21:52:18 +0600 |
commit | e72f0a0af5600589333070612e93ed5be3d06f7e (patch) | |
tree | 1d6758916b8de9d985320b316e6175f15a542655 /src | |
parent | 2272eaa7f0744c49449949a290de2fb65fa875c5 (diff) | |
download | vyconf-e72f0a0af5600589333070612e93ed5be3d06f7e.tar.gz vyconf-e72f0a0af5600589333070612e93ed5be3d06f7e.zip |
Add validate_any to Value_checker for testing if a value passes at least one test.
Diffstat (limited to 'src')
-rw-r--r-- | src/value_checker.ml | 6 | ||||
-rw-r--r-- | src/value_checker.mli | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/value_checker.ml b/src/value_checker.ml index ed7c5d1..245b769 100644 --- a/src/value_checker.ml +++ b/src/value_checker.ml @@ -16,3 +16,9 @@ let validate_value validators value_constraint value = | Unix.WEXITED 0 -> true | _ -> false with Not_found -> raise (Bad_validator t) + +let rec validate_any validators constraints value = + match constraints with + | [] -> false + | c :: cs -> if validate_value validators c value then true + else validate_any validators cs value diff --git a/src/value_checker.mli b/src/value_checker.mli index 96d8f3c..115ec9f 100644 --- a/src/value_checker.mli +++ b/src/value_checker.mli @@ -3,3 +3,5 @@ type value_constraint = Regex of string | External of string * string exception Bad_validator of string val validate_value : (string, string) Hashtbl.t -> value_constraint -> string -> bool + +val validate_any : (string, string) Hashtbl.t -> value_constraint list -> string -> bool |