Elgg  Version 6.1
ValidationResults.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Validation;
4 
9 
13  protected $results = [];
14 
24  public function pass($name, $value, $message = '') {
26  $result->pass($message);
27 
28  $this->results[$name] = $result;
29 
30  return $this;
31  }
32 
42  public function fail($name, $value, $error = '') {
44  $result->fail($error);
45 
46  $this->results[$name] = $result;
47 
48  return $this;
49  }
50 
55  public function all() {
56  return $this->results;
57  }
58 
63  public function getFailures() {
64  $failures = array_filter($this->results, function(ValidationResult $e) {
65  return !$e->isValid();
66  });
67 
68  return empty($failures) ? false : $failures;
69  }
70 }
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
Represents a set of validated parameters.
all()
Get all results in this bag.
fail($name, $value, $error= '')
Add parameter and set it as invalid.
$value
Definition: generic.php:51
$error
Bad request error.
Definition: 400.php:6
getFailures()
Check if the bag has parameters that failed validation.
$failures
Definition: register.php:24
Represents a parameter that has been validated.
isValid()
Is parameter value valid?
pass($name, $value, $message= '')
Add parameter and set it as valid.