let ref_seq
~name ~length
?assembly ?md5 ?species ?uri
()
=
let is_name_first_char_ok = function
| '!' .. ')' | '+' .. '<' | '>' .. '~' -> true
| _ -> false
in
let is_name_other_char_ok = function '!' .. '~' -> true | _ -> false in
(if (1 <= length) && (length <= 2147483647) then
Ok length
else
error "invalid reference sequence length" length sexp_of_int
) >>= fun length ->
(if (String.length name > 0)
&& (String.foldi name ~init:true ~f:(fun i accum c ->
accum && (
if i = 0 then is_name_first_char_ok c
else is_name_other_char_ok c
) ) )
then
Ok name
else
error "invalid ref seq name" name sexp_of_string
) >>= fun name ->
Ok {name; length; assembly; md5; species; uri}