Skip to content

Commit 7e7d453

Browse files
Various updates
1 parent 3b9782b commit 7e7d453

6 files changed

Lines changed: 29 additions & 22 deletions

File tree

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ An API key is required for this module to function.
2525

2626
1. Go to [https://www.mailboxvalidator.com](https://www.mailboxvalidator.com/plans#api) to sign up for FREE API plan if you do not have an API key.
2727

28-
2. After obtained your API key, load a ``.env`` file in your PHP application via ``Dotenv::load()``.
28+
2. (If you are at Symfony 4) After obtained your API key, load a ``.env`` file in your PHP application via ``Dotenv::load()``.
2929

3030
```php
3131
use Symfony\Component\Dotenv\Dotenv;
@@ -44,6 +44,16 @@ Notes: You need to install the MailboxValidator PHP Module in order to use this
4444

4545
## Usage
4646

47+
Before using the validator, be sure to add the bundle into the `config/bundles.php` file:
48+
49+
```PHP
50+
// config/bundles.php
51+
return [
52+
...
53+
MailboxValidatorBundle\MailboxValidatorBundle::class => ['all' => true],
54+
];
55+
```
56+
4757
The validators available to validate the email are: single, free and disposable. Each validator validate the email by using MailboxValidator API. For more information, you can visit [Single Validation API](https://www.mailboxvalidator.com/api-single-validation), [Disposable Email API](https://www.mailboxvalidator.com/api-email-disposable) and [Free Email API](https://www.mailboxvalidator.com/api-email-free).
4858

4959
1. To use any one of three validators or use all of the validators, include the following lines in any form controller that handle the validation:

composer.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"description": "Symfony bundle that used MailboxValidator API to validate email in form.",
55
"keywords": [
66
"Symfony",
7-
"Symfony4",
87
"validator",
98
"email",
109
"mailboxvalidator",
@@ -21,15 +20,13 @@
2120
],
2221
"require": {
2322
"php": ">=5.3",
24-
"symfony/symfony": "4.3.*",
25-
"symfony/validator": "4.3.*",
26-
"mailboxvalidator/mailboxvalidator-php": "2.0.*"
23+
"symfony/framework-bundle": "^7.2",
24+
"mailboxvalidator/mailboxvalidator-php": "2.*.*"
2725
},
2826
"require-dev": {
2927
"phpunit/phpunit": "7.5.*",
30-
"symfony/framework-bundle": "4.3.*",
31-
"symfony/validator": "4.3.*",
32-
"mailboxvalidator/mailboxvalidator-php": "2.0.*"
28+
"symfony/framework-bundle": "^7.2",
29+
"mailboxvalidator/mailboxvalidator-php": "2.*.*"
3330
},
3431
"autoload": {
3532
"psr-4": {
@@ -41,5 +38,5 @@
4138
"MailboxValidatorBundle\\Tests\\": "Tests/"
4239
}
4340
},
44-
"version": "2.0.0"
41+
"version": "2.1.0"
4542
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace MailboxValidator\MailboxValidatorBundle;
2+
namespace MailboxValidatorBundle;
33

44
use Symfony\Component\HttpKernel\Bundle\Bundle;
55

src/Validator/MBVDisposableValidator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class MBVDisposableValidator extends ConstraintValidator
1212
{
13-
public function validate($value, Constraint $constraint)
13+
public function validate(mixed $value, Constraint $constraint): void
1414
{
1515
/* @var $constraint \App\Validator\MBVDisposable */
1616

@@ -26,11 +26,11 @@ public function validate($value, Constraint $constraint)
2626

2727
if ($results === false) {
2828
return; //return "Error connecting to API."
29-
} else if (trim($results->error_code) == '') {
30-
if ($results->is_disposable == 'False') {
29+
} else if ((! isset($results->error_code)) && (isset($results->is_disposable))) {
30+
if (! $results->is_disposable) {
3131
return;
3232
}
33-
} else if (trim($results->error_code) != ''){
33+
} else if ((isset($results->error_code)) && (trim($results->error_code) != '')){
3434
return;
3535
}
3636

src/Validator/MBVFreeValidator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class MBVFreeValidator extends ConstraintValidator
1212
{
13-
public function validate($value, Constraint $constraint)
13+
public function validate(mixed $value, Constraint $constraint): void
1414
{
1515
/* @var $constraint \App\Validator\MBVFree */
1616

@@ -26,11 +26,11 @@ public function validate($value, Constraint $constraint)
2626

2727
if ($results === false) {
2828
return; //return "Error connecting to API."
29-
} else if (trim($results->error_code) == '') {
30-
if ($results->is_free == 'False') {
29+
} else if ((! isset($results->error_code)) && (isset($results->is_free))) {
30+
if (! $results->is_free) {
3131
return;
3232
}
33-
} else if (trim($results->error_code) != ''){
33+
} else if ((isset($results->error_code)) && (trim($results->error_code) != ''))
3434
return;
3535
}
3636

src/Validator/MBVSingleValidator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class MBVSingleValidator extends ConstraintValidator
1212
{
13-
public function validate($value, Constraint $constraint)
13+
public function validate(mixed $value, Constraint $constraint): void
1414
{
1515
/* @var $constraint \App\Validator\MBVSingle */
1616

@@ -26,11 +26,11 @@ public function validate($value, Constraint $constraint)
2626

2727
if ($results === false) {
2828
return; //return "Error connecting to API."
29-
} else if (trim($results->error_code) == '') {
30-
if ($results->status == 'True') {
29+
} else if (! isset($results->error_code)) {
30+
if ($results->status) {
3131
return;
3232
}
33-
} else if (trim($results->error_code) != ''){
33+
} else if ((isset($results->error_code)) && (trim($results->error_code) != ''))
3434
return;
3535
}
3636

0 commit comments

Comments
 (0)