Input.postAll
$data.postAll($fieldsRulesMap) -> map
Description
Validate multiple input fields and get their values.
Validation
Each input value will be validated per its validation rule. (See Input Validation)
The function will return a Map with the following fields:
ok
.true
if all fields passed validation.fields
. A map of all fields and their values. (ifok
is true)errors
. A list of all field errors. (ifok
is false)
Example
fun mainPost { $data = Input.postAll({ userId: 'id' age: 'i|min:1|max:130' }) if $data.ok { print $data.fields.age } else { print($data.errors) } } // Post: { userId: 100, age: 33 } //= 33 // Post: { userId: 100, age: 1000 } // [ // { field: 'age', error: 'Must be 130 or less.' } // ]