Custom Server-Side Validator Element

Getting Started | API | Elements | Actions | Validators | Handlers | About

Table of Contents

1 Custom Server-Side Validator - #custom {}

Attach a custom validator, written in Erlang, to an element. The validator will be executed on the server during a postback.

1.1 Usage

% Function to validate that a value is either upper or lower case,
% depending on the value of Tag...
F = fun(Tag, Value) ->
  case Tag of
    upper -> string:to_upper(Value) == Value;
    lower -> string:to_upper(Value) == Value
  end
end,
     
% Wire the validator in upper case mode...
wf:wire(ButtonID, TextBoxID, #validate { validators=[
  #custom { text="Must be uppercase", function=F, tag=upper }
]})

1.2 Attributes

text - (string)
The text to display if validation fails.
function - (fun)
An Erlang function that returns true if the value is valid, false if invalid. <br>fun(Tag, Value) -> 'true' or 'false'
tag - (Erlang term)
Tag value is passed into the custom validation function.

Author: Rusty Klophaus (@rklophaus) <>

Date: 2010-06-14 18:34:58 EDT

HTML generated by org-mode 6.33f in emacs 22