View difference between Paste ID: JGdkmavn and dJJL4Vzj
SHOW: | | - or go back to the newest paste.
1
let check predicate msg () =
2
  if not predicate then
3
    Some msg
4
  else
5
    None
6
7
let tryLogin() =
8
  let msgOpt = 
9
    [
10
      $_POST['user_name'], "Empty Username"
11
      $_POST['user_password_new'], "EmptyPassword"
12
      ....
13
      ... , "You must provide valid e-mail address"
14
    ]
15-
    |> List.map (fun (pred, msg) -> check (msg))
15+
    |> List.map (fun (pred, msg) -> check (pred, msg))
16
    |> List.<getFirstNotNone> (fun check -> check())
17
18
  match msgOpt with
19
  | Some msg -> msg
20
  | None ->
21
    <body>
22
    ""
23
24
let register() =
25
  if not <| empty($_POST) then
26
    $_SESSION["msg"] <- tryLogin()
27
28
  register_form()