Skip to content
Discussion options

You must be logged in to vote

@g3r0me you can use a custom rule closure. You can learn more about our validation library we use for our fields here.

\Give\Framework\FieldsAPI\Date::make('birthday')
    ->rules(function ($value, Closure $fail, string $key, array $values) {
        $today = new DateTime('today');
        $date = new DateTime($value);
        if ($date->diff($today)->y < 18) {
            $fail('You must be at least 18 years old to donate.');
        }
    });

\Give\Framework\FieldsAPI\Text::make('id_num')
    ->rules(function ($value, Closure $fail, string $key, array $values) {
        $today = new DateTime('today');
        $date = new DateTime($values['birthday']);
        if ($date->diff($today)->y < 

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by g3r0me
Comment options

You must be logged in to vote
1 reply
@jonwaldstein
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants