forked from inhere/php-validate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidationInterface.php
More file actions
93 lines (80 loc) · 1.7 KB
/
Copy pathValidationInterface.php
File metadata and controls
93 lines (80 loc) · 1.7 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php declare(strict_types=1);
/**
* @author inhere
* @date : 2015-08-11
*/
namespace Inhere\Validate;
use stdClass;
/**
* Interface ValidationInterface
*
* @package Inhere\Validate
*/
interface ValidationInterface
{
/**
* @return array
*/
public function rules(): array;
/**
* custom validator's message, to override default message.
*
* @return array
*/
public function messages(): array;
/**
* define attribute field translate list
*
* @return array
*/
public function translates(): array;
/**
* Data validation
*
* @param array $onlyChecked 可以设置此次需要验证的字段
* @param bool|null $stopOnError 是否出现错误即停止验证
*
* @return static
*/
public function validate(array $onlyChecked = [], bool $stopOnError = null);
/**
* alias of the fail()
*
* @return bool
*/
public function isFail(): bool;
/**
* @return bool
*/
public function isPassed(): bool;
/**
* @param string $field
*
* @return array
*/
public function getErrors(string $field = ''): array;
/**
* Get the first error message
*
* @param bool $onlyMsg Only return message string.
*
* @return array|string
*/
public function firstError(bool $onlyMsg = true);
/**
* Get the last error message
*
* @param bool $onlyMsg
*
* @return array|string
*/
public function lastError(bool $onlyMsg = true);
/**
* @return array
*/
public function getMessages(): array;
/**
* @return array|stdClass
*/
public function getSafeData();
}