Skip to content

Commit

Permalink
feat: cria novas regras de validaçao
Browse files Browse the repository at this point in the history
 - Email
 - RegExp
  • Loading branch information
valdeir2000 committed Aug 9, 2020
1 parent eaf91a4 commit 35ba9ce
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
17 changes: 17 additions & 0 deletions upload/system/library/PagSeguro/src/Validation/Rules/Email.php
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 upload/system/library/PagSeguro/src/Validation/Rules/Regex.php
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);
}
}

0 comments on commit 35ba9ce

Please sign in to comment.