File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change 4
4
5
5
use IgniteKit \Validation \Rule ;
6
6
7
- class Present extends Rule
8
- {
7
+ class Present extends Rule {
9
8
/** @var bool */
10
9
protected $ implicit = true ;
11
10
@@ -16,10 +15,24 @@ class Present extends Rule
16
15
* Check the $value is valid
17
16
*
18
17
* @param mixed $value
18
+ *
19
19
* @return bool
20
20
*/
21
- public function check ($ value ): bool
22
- {
23
- return $ this ->validation ->hasValue ($ this ->attribute ->getKey ());
21
+ public function check ( $ value ): bool {
22
+
23
+ $ this ->setAttributeAsRequired ();
24
+
25
+ return $ this ->validation ->hasValue ( $ this ->attribute ->getKey () );
26
+ }
27
+
28
+ /**
29
+ * Set attribute is required if $this->attribute is set
30
+ *
31
+ * @return void
32
+ */
33
+ protected function setAttributeAsRequired () {
34
+ if ( $ this ->attribute ) {
35
+ $ this ->attribute ->setRequired ( true );
36
+ }
24
37
}
25
38
}
You can’t perform that action at this time.
0 commit comments