module Ti_validate:sig..end
Add a validator to a Text_input
A validator is a small icon, located next to a Text entry, indicating whether the text typed by the user is "valid" under certain rules (for instance, a valid email address). In strict mode, the validator can also completely prevent the user from typing any invalid string.
type t
typestatus =bool option
String status:
typevalidator =string -> status * string option
A validator function takes a string that the user has typed in the Text_input widget, and returns:
val get_status : t -> status
val get_layout : t -> Layout.t
val get_text_input : t -> Widget.t
val get_text : t -> string
val regexp_validator : ?strict:bool -> string -> validatorConstruct a validator function from a regular expression. If strîct is
true, the complete string must match the complete regular expression to
validate. Only valid text is allowed (so make sure that the default string
does validate!)
If strict=false, the status stays "undecided" as long as the whole string
is a prefix of a potential string that would strictly match. Thus, the user
is allowed to type strings that are "not complete yet".
val make : validator ->
?bg:Draw.rgb ->
?prompt:string -> ?size:int -> string -> tReturn a layout containing a Text Entry and a Validity indicator; also return a function to examine the validity of the last user entry.
val of_regexp : ?strict:bool ->
string ->
?bg:Draw.rgb ->
?prompt:string -> ?size:int -> string -> tSame as Ti_validate.make, with a validator obtained from a regular expression via
Ti_validate.regexp_validator.
module Email:sig..end
Implement email validation following HTML specs.