webCOMAND

validate::post()

Retrieve and validate an HTTP POST query parameter values.

Prototype

string post(string $key, array $validations, string $invalid_message = NULL)

Parameters

  • key - Name of the parameter to retrieve.
  • validations - An array of validate strings or object/method pairs.
  • invalid_message - Message to log in validation error if the value does not pass all validations.

Return

Returns the value, even if it does not validate.  Check validate::valid() to determine if the value is valid.

Example

$validate = new \io_comand_web\validate();
$validate->post('email',
    ['trim', 'required', 'email'],
    'Invalid email address'
);
if($validate->valid()) {
    echo('Email is valid.');
}

Related

valid(), validation_errors()