Skip to content

Commit

Permalink
Added EmailAddress regex (#30)
Browse files Browse the repository at this point in the history
* Added email regex

* Improved the regex to allow longer tld

* Updated failing test case to account for new core regex class.

---------

Co-authored-by: Yorda <yordadevs@gmail.com>
  • Loading branch information
JorgeAnzola and yordadev authored Apr 12, 2023
1 parent 7992560 commit c3e8f76
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/RegexCollection/EmailAddress.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace YorCreative\Scrubber\RegexCollection;

use YorCreative\Scrubber\Interfaces\RegexCollectionInterface;

class EmailAddress implements RegexCollectionInterface
{
public function getPattern(): string
{
return '[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,63}';
}

public function getTestableString(): string
{
return 'johndoe321@example.associates';
}

public function isSecret(): bool
{
return false;
}
}
2 changes: 2 additions & 0 deletions src/Repositories/RegexCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ class RegexCollection
public static string $TWILIO_ACCOUNT_SID = 'TwilioAccountSid';

public static string $TWILIO_APP_SID = 'TwilioAppSid';

public static string $EMAIL_ADDRESS = 'EmailAddress';
}
2 changes: 1 addition & 1 deletion tests/Unit/Strategies/RegexLoaderStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RegexLoaderStrategyTest extends TestCase
*/
public function it_can_load_default_core()
{
$this->assertCount(25, app(RegexLoaderStrategy::class)->load());
$this->assertCount(26, app(RegexLoaderStrategy::class)->load());
}

/**
Expand Down

0 comments on commit c3e8f76

Please sign in to comment.