$59 GRAYBYTE WORDPRESS FILE MANAGER $31

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 104.21.43.35 | ADMIN IP 216.73.216.157
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : mail

/home/bravrvjk/itiministry.org/wp-content/plugins/give/src/DonationForms/Rules/

HOME
Current File : /home/bravrvjk/itiministry.org/wp-content/plugins/give/src/DonationForms/Rules//CurrencyRule.php
<?php

namespace Give\DonationForms\Rules;

use Closure;
use Give\Framework\Support\Currencies\GiveCurrencies;
use Give\Vendors\StellarWP\Validation\Contracts\ValidationRule;
use Money\Currency;

/**
 * Custom currency validation rule that uses GiveWP's currency list and filter.
 * Replaces the generic stellar validation library currency rule to ensure consistency
 * with GiveWP's configured currencies and filters.
 *
 * @since 4.10.0
 */
class CurrencyRule implements ValidationRule
{
    /**
     * @since 4.10.0
     */
    public static function id(): string
    {
        return 'giveCurrency';
    }

    /**
     * @since 4.10.0
     */
    public static function fromString(string $options = null): ValidationRule
    {
        return new self();
    }

    /**
     * Validates that the currency code is in GiveWP's supported currency list.
     * Uses give_get_currencies_list() to get the current supported currencies
     * and provides clear error messages with valid currency options.
     *
     * @since 4.10.0
     */
    public function __invoke($value, Closure $fail, string $key, array $values)
    {
        // Check format first for better error messaging
        if (!$this->isValidFormat($value)) {
            $fail(
                sprintf(
                    __('%s must be a valid 3-letter currency code in uppercase format (example: USD)', 'give'),
                    '{field}'
                )
            );
        } elseif (!give(GiveCurrencies::class)->contains(new Currency($value))) {
            $fail(
                sprintf(
                    __('%s must be a valid currency. Provided: %s', 'give'),
                    '{field}',
                    $value
                )
            );
        }
    }

    /**
     * Checks if a currency code is in the correct ISO 4217 format.
     * Valid format: exactly 3 uppercase alphabetic characters (not empty).
     *
     * @since 4.10.0
     *
     * @param mixed $value The currency code to validate
     * @return bool True if the format is valid, false otherwise
     */
    private function isValidFormat($value): bool
    {
        return is_string($value) && !empty($value) && strlen($value) === 3 && ctype_alpha($value) && $value === strtoupper($value);
    }
}


Current_dir [ WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
8 Apr 2026 3.24 AM
bravrvjk / bravrvjk
0755
ArrayRule.php
1.287 KB
16 Oct 2023 9.55 PM
bravrvjk / bravrvjk
0644
AuthenticationRule.php
0.661 KB
16 Oct 2023 9.55 PM
bravrvjk / bravrvjk
0644
BillingAddressCityRule.php
0.747 KB
16 Oct 2023 9.55 PM
bravrvjk / bravrvjk
0644
BillingAddressStateRule.php
0.746 KB
16 Oct 2023 9.55 PM
bravrvjk / bravrvjk
0644
BillingAddressZipRule.php
0.748 KB
16 Oct 2023 9.55 PM
bravrvjk / bravrvjk
0644
CurrencyRule.php
2.216 KB
1 Oct 2025 3.37 PM
bravrvjk / bravrvjk
0644
DonationTypeRule.php
1.484 KB
16 Oct 2023 9.55 PM
bravrvjk / bravrvjk
0644
GatewayRule.php
1.381 KB
16 Oct 2023 9.55 PM
bravrvjk / bravrvjk
0644
HoneyPotRule.php
0.956 KB
26 Sep 2024 1.57 AM
bravrvjk / bravrvjk
0644
Max.php
1.208 KB
16 Oct 2023 9.55 PM
bravrvjk / bravrvjk
0644
Min.php
1.208 KB
16 Oct 2023 9.55 PM
bravrvjk / bravrvjk
0644
PhoneIntlInputRule.php
1.127 KB
24 Apr 2024 7.56 PM
bravrvjk / bravrvjk
0644
Size.php
2.574 KB
16 Oct 2023 9.55 PM
bravrvjk / bravrvjk
0644
SubscriptionFrequencyRule.php
0.924 KB
16 Oct 2023 9.55 PM
bravrvjk / bravrvjk
0644
SubscriptionInstallmentsRule.php
0.93 KB
16 Oct 2023 9.55 PM
bravrvjk / bravrvjk
0644
SubscriptionPeriodRule.php
1.76 KB
16 Oct 2023 9.55 PM
bravrvjk / bravrvjk
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF