Skip to content

Commit

Permalink
add myanmar_phone_number validation rule
Browse files Browse the repository at this point in the history
  • Loading branch information
PyaeSoneAungRgn committed Nov 5, 2023
1 parent 53e83a6 commit b91034a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/LaravelMyanmarToolsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ private function registerCarbonMacros(): void

private function registerLang(): void
{
$this->loadTranslationsFrom(__DIR__.'/../resources/lang', $this->getPackageName());
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', $this->getPackageName());
$this->publishes([
__DIR__.'/../resources/lang' => base_path('/lang/vendor/'.$this->getPackageName()),
__DIR__ . '/../resources/lang' => base_path('/lang/vendor/' . $this->getPackageName()),
]);
}

Expand Down Expand Up @@ -207,6 +207,7 @@ private function validatorExtends(): array
{
return [
'myanmarPhoneNumber' => \PyaeSoneAung\LaravelMyanmarTools\Macros\Validator\MyanmarPhoneNumber::class,
'myanmar_phone_number' => \PyaeSoneAung\LaravelMyanmarTools\Macros\Validator\MyanmarPhoneNumber::class,
'mpt' => \PyaeSoneAung\LaravelMyanmarTools\Macros\Validator\Mpt::class,
'ooredoo' => \PyaeSoneAung\LaravelMyanmarTools\Macros\Validator\Ooredoo::class,
'telenor' => \PyaeSoneAung\LaravelMyanmarTools\Macros\Validator\Telenor::class,
Expand Down Expand Up @@ -234,6 +235,6 @@ private function getPackageName(): string

private function getErrorMessage($extend): mixed
{
return trans($this->getPackageName().'::validation.'.Str::snake($extend));
return trans($this->getPackageName() . '::validation.' . Str::snake($extend));
}
}
4 changes: 4 additions & 0 deletions tests/Feature/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public function it_can_validate_myanmar_phone_number()
$this->assertTrue(Validator::make(['phone' => '09250000000'], [
'phone' => 'myanmarPhoneNumber',
])->passes());

$this->assertTrue(Validator::make(['phone' => '09250000000'], [
'phone' => 'myanmar_phone_number',
])->passes());
}

/** @test */
Expand Down

0 comments on commit b91034a

Please sign in to comment.