Version: v0.7.1 - Beta.  We welcome contributors & feedback.

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:

Example

fn 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.' },
// ]

See Also