Multiply the values for the validator

I’m attempting to create a form validator where I aim to verify whether the post associated with the InternID (handset) contains a properly formatted email address.

    'projectemail' => function ($values) {
      $projectID = $values['projectid']; 
      $email = $values['email'];

      $submission = ($p = kirby()->site()->index($drafts = true)->filterBy('template', 'post')->findBy('InternID', $projectID)) ? $p->Email() : null;
      return V::in($email, [$submission]);
    },

My rule is.

  $rules = [
            "projectemail" => [
              "projectemail",
              [$data['projectid'], $data['email']]  
            ]
          ];

This won’t work for multiple reasons. The rules apply to a single field value only, i.e. the field used as key.

I think you would be better off validating your email separately from those rules.

Ah ok.

Oky maybe best I will check the values later in my php Controller.

I thought I could load all post by the id and check in this post if it has the email.