summaryrefslogtreecommitdiff
path: root/src/couch/src/couch_util.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/couch/src/couch_util.erl')
-rw-r--r--src/couch/src/couch_util.erl12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/couch/src/couch_util.erl b/src/couch/src/couch_util.erl
index a785e2e44..2e06b0911 100644
--- a/src/couch/src/couch_util.erl
+++ b/src/couch/src/couch_util.erl
@@ -31,6 +31,7 @@
-export([with_db/2]).
-export([rfc1123_date/0, rfc1123_date/1]).
-export([integer_to_boolean/1, boolean_to_integer/1]).
+-export([validate_positive_int/1]).
-export([find_in_binary/2]).
-export([callback_exists/3, validate_callback_exists/3]).
-export([with_proc/4]).
@@ -621,6 +622,17 @@ boolean_to_integer(false) ->
0.
+validate_positive_int(N) when is_list(N) ->
+ try
+ I = list_to_integer(N),
+ validate_positive_int(I)
+ catch error:badarg ->
+ false
+ end;
+validate_positive_int(N) when is_integer(N), N > 0 -> true;
+validate_positive_int(_) -> false.
+
+
find_in_binary(_B, <<>>) ->
not_found;