ArrayRule.php
2 years ago
AuthenticationRule.php
2 years ago
BillingAddressCityRule.php
2 years ago
BillingAddressStateRule.php
2 years ago
BillingAddressZipRule.php
2 years ago
DonationTypeRule.php
2 years ago
GatewayRule.php
2 years ago
HoneyPotRule.php
1 year ago
Max.php
2 years ago
Min.php
2 years ago
PhoneIntlInputRule.php
2 years ago
Size.php
2 years ago
SubscriptionFrequencyRule.php
2 years ago
SubscriptionInstallmentsRule.php
2 years ago
SubscriptionPeriodRule.php
2 years ago
SubscriptionFrequencyRule.php
42 lines
| 1 | <?php |
| 2 | namespace Give\DonationForms\Rules; |
| 3 | |
| 4 | use Closure; |
| 5 | use Give\Donations\ValueObjects\DonationType; |
| 6 | use Give\Vendors\StellarWP\Validation\Contracts\ValidatesOnFrontEnd; |
| 7 | use Give\Vendors\StellarWP\Validation\Contracts\ValidationRule; |
| 8 | |
| 9 | class SubscriptionFrequencyRule implements ValidationRule, ValidatesOnFrontEnd |
| 10 | { |
| 11 | |
| 12 | /** |
| 13 | * @since 3.0.0 |
| 14 | */ |
| 15 | public static function id(): string |
| 16 | { |
| 17 | return 'subscriptionFrequency'; |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * @since 3.0.0 |
| 22 | */ |
| 23 | public static function fromString(string $options = null): ValidationRule |
| 24 | { |
| 25 | return new self(); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * @since 3.0.0 |
| 30 | */ |
| 31 | public function __invoke($value, Closure $fail, string $key, array $values): bool |
| 32 | { |
| 33 | $donationType = new DonationType($values['donationType']); |
| 34 | |
| 35 | return $donationType->isSubscription() && is_numeric($value); |
| 36 | } |
| 37 | |
| 38 | public function serializeOption() |
| 39 | { |
| 40 | return null; |
| 41 | } |
| 42 | } |