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 44
55use IgniteKit \Validation \Rule ;
66
7- class Present extends Rule
8- {
7+ class Present extends Rule {
98 /** @var bool */
109 protected $ implicit = true ;
1110
@@ -16,10 +15,24 @@ class Present extends Rule
1615 * Check the $value is valid
1716 *
1817 * @param mixed $value
18+ *
1919 * @return bool
2020 */
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+ }
2437 }
2538}
You can’t perform that action at this time.
0 commit comments