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
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
BillingAddressStateRule.php
38 lines
| 1 | <?php |
| 2 | namespace Give\DonationForms\Rules; |
| 3 | |
| 4 | use Closure; |
| 5 | use Give\Vendors\StellarWP\Validation\Contracts\ValidationRule; |
| 6 | |
| 7 | /** |
| 8 | * @since 3.0.0 |
| 9 | */ |
| 10 | class BillingAddressStateRule implements ValidationRule |
| 11 | { |
| 12 | /** |
| 13 | * @since 3.0.0 |
| 14 | */ |
| 15 | public static function id(): string |
| 16 | { |
| 17 | return 'state'; |
| 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) |
| 32 | { |
| 33 | if ( !$value && !array_key_exists( $values['country'], give_states_not_required_country_list() ) ) { |
| 34 | $fail(__('State required.', 'give')); |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 |