-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIValidator.php
45 lines (39 loc) · 1.21 KB
/
IValidator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/*
* Opulence
*
* @link https://www.opulencephp.com
* @copyright Copyright (C) 2021 David Young
* @license https://github.com/opulencephp/Opulence/blob/1.2/LICENSE.md
*/
namespace Opulence\Validation;
use Opulence\Validation\Rules\Errors\ErrorCollection;
use Opulence\Validation\Rules\Rules;
/**
* Defines the interface for validators to implement
*/
interface IValidator
{
/**
* Creates rules for a field
*
* @param string $name The name of the field to create rules for
* @return Rules The rules for the input field
*/
public function field(string $name) : Rules;
/**
* Gets the list of errors
*
* @return ErrorCollection The list of errors
*/
public function getErrors() : ErrorCollection;
/**
* Checks if a list of values are valid
*
* @param array $allValues The name => value mappings to validate
* @param bool $haltFieldValidationOnFailure True if we want to not check any other rules for a field
* once one fails, otherwise false
* @return bool True if the values were valid, otherwise false
*/
public function isValid(array $allValues, bool $haltFieldValidationOnFailure = false) : bool;
}