PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / Framework / FieldsAPI / Concerns / HasMinLength.php

HasMinLength.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Framework/FieldsAPI/Concerns/HasMinLength.php

47 lines 957 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Framework\FieldsAPI\Concerns;
4
5 use Give\Vendors\StellarWP\Validation\Rules\Min;
6
7 /**
8 * @since 2.24.0 update to new validation system
9 * @since 2.14.0
10 */
11 trait HasMinLength
12 {
13 /**
14 * Set the value’s minimum length.
15 *
16 * @since 2.24.0 update to new validation system
17 * @since 2.14.0
18 */
19 public function minLength(int $minLength): self
20 {
21 if ( $this->hasRule('min') ) {
22 /** @var Min $rule */
23 $rule = $this->getRule('min');
24 $rule->size($minLength);
25 }
26
27 $this->rules("min:$minLength");
28
29 return $this;
30 }
31
32 /**
33 * Get the value’s minimum length.
34 *
35 * @since 2.24.0 update to use the new validation system
36 * @since 2.14.0
37 *
38 * @return int|null
39 */
40 public function getMinLength()
41 {
42 $rule = $this->getRule('min');
43
44 return $rule instanceof Min ? $rule->getSize() : null;
45 }
46 }
47