input_validate(fn f, string failure_message[, number max_times]) ⇒ mixed
Reads input until the supplied function accepts it, optionally stopping after a maximum number of attempts.
This function was originally a predefined function introduced in ZPE 1.7.3. It is now provided by the Validation module.
Examples
The validator can use a named function and its handle:
YASS
function check($x) if ($x == "password") return true else return false end if end function $value = Validation::input_validate( handle_of(check), "Incorrect password." ) print($value)
An inline validator can check that a number is within a range:
YASS
$number = Validation::input_validate( function($x) $x = value($x) return $x > 10 and $x < 100 end function, "Number must be between 10 and 100." ) print($number)
A regular-expression validator can check a capitalised name:
YASS
$name = Validation::input_validate( function($x) return string_matches($x, "[A-Z][a-z]+") end function, "Name must start with a capital letter.", 3 ) print($name)

There are no comments on this page.
Comments are welcome and encouraged, including disagreement and critique. However, this is not a space for abuse. Disagreement is welcome; personal attacks, harassment, or hate will be removed instantly. This site reflects personal opinions, not universal truths. If you can’t distinguish between the two, this probably isn’t the place for you. The system temporarily stores IP addresses and browser user agents for the purposes of spam prevention, moderation, and safeguarding. This data is automatically removed after fourteen days. Your email address is stored so that replies can be sent to your email address.
Comments powered by BalfComment