-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathValidatingInterface.php
More file actions
182 lines (158 loc) · 3.79 KB
/
ValidatingInterface.php
File metadata and controls
182 lines (158 loc) · 3.79 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
namespace Watson\Validating;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\MessageBag;
use Illuminate\Validation\Factory;
interface ValidatingInterface
{
/**
* Returns whether or not the model will attempt to validate
* itself when saving.
*
* @return bool
*/
public function getValidating();
/**
* Set whether the model should attempt validation on saving.
*
* @param bool $value
* @return void
*/
public function setValidating($value);
/**
* Returns whether the model will raise an exception or
* return a boolean when validating.
*
* @return bool
*/
public function getThrowValidationExceptions();
/**
* Set whether the model should raise an exception or
* return a boolean on a failed validation.
*
* @param bool $value
* @return void
*
* @throws InvalidArgumentException
*/
public function setThrowValidationExceptions($value);
/**
* Returns whether or not the model will add it's unique
* identifier to the rules when validating.
*
* @return bool
*/
public function getInjectUniqueIdentifier();
/**
* Set the model to add unique identifier to rules when performing
* validation.
*
* @param bool $value
* @return void
*
* @throws InvalidArgumentException
*/
public function setInjectUniqueIdentifier($value);
/**
* Get the model.
*
* @return Model
*/
public function getModel();
/**
* Get the casted model attributes.
*
* @return array
*/
public function getModelAttributes();
/**
* Get the global validation rules.
*
* @return array
*/
public function getRules();
/**
* Set the global validation rules.
*
* @return void
*/
public function setRules(?array $rules = null);
/**
* Get the validation error messages from the model.
*
* @return MessageBag
*/
public function getErrors();
/**
* Set the error messages.
*
* @return void
*/
public function setErrors(MessageBag $validationErrors);
/**
* Returns whether the model is valid or not.
*
* @return bool
*/
public function isValid();
/**
* Returns if the model is valid, otherwise throws an exception.
*
* @return bool
*
* @throws ValidationException
*/
public function isValidOrFail();
/**
* Returns whether the model is invalid or not.
*
* @return bool
*/
public function isInvalid();
/**
* Force the model to be saved without undergoing validation.
*
* @return bool
*/
public function forceSave();
/**
* Perform a one-off save that will raise an exception on validation error
* instead of returning a boolean (which is the default behaviour).
*
* @return void
*
* @throws ValidationException
*/
public function saveOrFail();
/**
* Perform a one-off save that will return a boolean on
* validation error instead of raising an exception.
*
* @return bool
*/
public function saveOrReturn();
/**
* Get the Validator instance
*
* @return Factory
*/
public function getValidator();
/**
* Set the Validator instance
*/
public function setValidator(Factory $validator);
/**
* Throw a validation exception.
*
* @throws ValidationException
*/
public function throwValidationException();
/**
* Update the unique rules of the global rules to
* include the model identifier.
*
* @return void
*/
public function updateRulesUniques();
}