-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cria novas regras de validaçao
- Email - RegExp
- Loading branch information
1 parent
eaf91a4
commit 35ba9ce
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
upload/system/library/PagSeguro/src/Validation/Rules/Email.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace ValdeirPsr\PagSeguro\Validation\Rules; | ||
|
||
/** | ||
* Valida um e-mail | ||
*/ | ||
class Email implements IValidation | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function validate($input): bool | ||
{ | ||
return filter_var($input, FILTER_VALIDATE_EMAIL); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
upload/system/library/PagSeguro/src/Validation/Rules/Regex.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace ValdeirPsr\PagSeguro\Validation\Rules; | ||
|
||
/** | ||
* Valida um valor através de uma expressão regular | ||
*/ | ||
class Regex implements IValidation | ||
{ | ||
private $regex; | ||
|
||
public function __construct(string $regex) | ||
{ | ||
$this->regex = $regex; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function validate($input): bool | ||
{ | ||
return preg_match($this->regex, $input); | ||
} | ||
} |