mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-20 17:46:03 +02:00
Even more work on contact validation
This commit is contained in:
parent
159228e303
commit
19a4dc4048
3 changed files with 33 additions and 7 deletions
|
@ -7,6 +7,10 @@ use Psr\Http\Message\ResponseInterface as Response;
|
|||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use League\ISO3166\ISO3166;
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\Validation\DNSCheckValidation;
|
||||
use Egulias\EmailValidator\Validation\MultipleValidationWithAnd;
|
||||
use Egulias\EmailValidator\Validation\RFCValidation;
|
||||
|
||||
class ContactsController extends Controller
|
||||
{
|
||||
|
@ -561,7 +565,7 @@ class ContactsController extends Controller
|
|||
[ $contact['id'] ]);
|
||||
$contactPostal = $db->select('SELECT * FROM contact_postalInfo WHERE contact_id = ?',
|
||||
[ $contact['id'] ]);
|
||||
|
||||
|
||||
$responseData = [
|
||||
'contact' => $contact,
|
||||
'contactStatus' => $contactStatus,
|
||||
|
@ -584,6 +588,27 @@ class ContactsController extends Controller
|
|||
$responseData['verifyEmail'] = $verifyEmail;
|
||||
$responseData['verifyPostal'] = $verifyPostal;
|
||||
}
|
||||
|
||||
if ($verifyPhone == 'on') {
|
||||
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
|
||||
try {
|
||||
$numberProto = $phoneUtil->parse($contact['voice'], $contactPostal[0]['cc']);
|
||||
$isValid = $phoneUtil->isValidNumber($numberProto);
|
||||
$responseData['phoneDetails'] = $isValid;
|
||||
} catch (\libphonenumber\NumberParseException $e) {
|
||||
$responseData['phoneDetails'] = $e;
|
||||
}
|
||||
}
|
||||
|
||||
if ($verifyEmail == 'on') {
|
||||
$validator = new EmailValidator();
|
||||
$multipleValidations = new MultipleValidationWithAnd([
|
||||
new RFCValidation(),
|
||||
new DNSCheckValidation()
|
||||
]);
|
||||
$isValid = $validator->isValid($contact['email'], $multipleValidations);
|
||||
$responseData['emailDetails'] = $isValid;
|
||||
}
|
||||
|
||||
return view($response, 'admin/contacts/validateContact.twig', $responseData);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue