package validate

  1. Overview
  2. Docs

Source file value.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
open Err

let validate_equal_to to_str other value =
  if other = value then Ok ()
  else
    Error
      (BaseError
         {
           code = value_equal_to_error_code;
           params = [ ("value", to_str other) ];
         })

let validate_not_equal_to to_str other value =
  if other <> value then Ok ()
  else
    Error
      (BaseError
         {
           code = value_not_equal_to_error_code;
           params = [ ("value", to_str other) ];
         })

let validate_greater_than to_str other value =
  if value > other then Ok ()
  else
    Error
      (BaseError
         {
           code = value_greater_than_error_code;
           params = [ ("threshold", to_str other) ];
         })

let validate_greater_than_or_equal to_str other value =
  if value >= other then Ok ()
  else
    Error
      (BaseError
         {
           code = value_greater_than_or_equal_error_code;
           params = [ ("threshold", to_str other) ];
         })

let validate_less_than to_str other value =
  if value < other then Ok ()
  else
    Error
      (BaseError
         {
           code = value_less_than_error_code;
           params = [ ("threshold", to_str other) ];
         })

let validate_less_than_or_equal to_str other value =
  if value <= other then Ok ()
  else
    Error
      (BaseError
         {
           code = value_less_than_or_equal_error_code;
           params = [ ("threshold", to_str other) ];
         })
OCaml

Innovation. Community. Security.