18 lines
428 B
OCaml
18 lines
428 B
OCaml
type name = string
|
|
type userinfo = { username : string; realname : string }
|
|
|
|
let name_type s =
|
|
let rec valid i =
|
|
if i >= String.length s then true
|
|
else
|
|
match s.[i] with
|
|
| ' ' | '@' | '+' | ',' -> false
|
|
| _ -> valid (i + 1)
|
|
in
|
|
if s = "" then `invalid
|
|
else
|
|
match s.[0] with
|
|
| ':' -> `invalid
|
|
| '#' -> if valid 1 then `chan else `invalid
|
|
| _ -> if valid 0 then `nick else `invalid
|