1 | <?php |
||
2 | |||
3 | |||
4 | namespace Larapie\Actions\Attributes\Rules; |
||
5 | |||
6 | |||
7 | trait StringRules |
||
8 | { |
||
9 | public function size(int $size) |
||
10 | { |
||
11 | return $this->rule("size:$size"); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
12 | } |
||
13 | |||
14 | 1 | public function min(int $length) |
|
15 | { |
||
16 | 1 | return $this->rule("min:$length"); |
|
17 | } |
||
18 | |||
19 | 1 | public function max(int $length) |
|
20 | { |
||
21 | 1 | return $this->rule("max:$length"); |
|
22 | } |
||
23 | |||
24 | 1 | public function email() |
|
25 | { |
||
26 | 1 | return $this->rule('email:rfc,dns'); |
|
27 | } |
||
28 | |||
29 | public function startsWith(string ...$values) |
||
30 | { |
||
31 | return $this->rule('starts_with:' . implode(',', $values)); |
||
32 | } |
||
33 | |||
34 | 1 | public function endsWith(string ...$values) |
|
35 | { |
||
36 | 1 | return $this->rule('ends_with:' . implode(',', $values)); |
|
37 | } |
||
38 | |||
39 | public function in(string ...$values) |
||
40 | { |
||
41 | return $this->rule('in:' . implode(',', $values)); |
||
42 | } |
||
43 | |||
44 | public function notIn(string ...$values) |
||
45 | { |
||
46 | return $this->rule('not_in:' . implode(',', $values)); |
||
47 | } |
||
48 | |||
49 | public function notRegex(string $regex) |
||
50 | { |
||
51 | return $this->rule("regex:$regex"); |
||
52 | } |
||
53 | |||
54 | public function regex(string $regex) |
||
55 | { |
||
56 | return $this->rule("regex:$regex"); |
||
57 | } |
||
58 | |||
59 | public function ip() |
||
60 | { |
||
61 | return $this->rule('ip'); |
||
62 | } |
||
63 | |||
64 | public function ipv4() |
||
65 | { |
||
66 | return $this->rule('ipv4'); |
||
67 | } |
||
68 | |||
69 | public function ipv6() |
||
70 | { |
||
71 | return $this->rule('ipv6'); |
||
72 | } |
||
73 | |||
74 | public function json() |
||
75 | { |
||
76 | return $this->rule('json'); |
||
77 | } |
||
78 | |||
79 | public function password(?string $guard = null) |
||
80 | { |
||
81 | if ($guard === null) |
||
82 | return $this->rule('guard'); |
||
83 | return $this->rule("guard:$guard"); |
||
84 | } |
||
85 | |||
86 | public function timezone() |
||
87 | { |
||
88 | return $this->rule('timezone'); |
||
89 | } |
||
90 | } |