-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
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
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
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,46 @@ | ||
<?php | ||
|
||
namespace Ofcold\IdentityCard\Rules; | ||
|
||
use Illuminate\Contracts\Validation\Rule; | ||
use Ofcold\IdentityCard\IdentityCard; | ||
|
||
/** | ||
* class IdCard | ||
* | ||
* PHP business application development core system | ||
* | ||
* This content is released under the Business System Toll License (MST) | ||
* | ||
* @link https://ofcold.com | ||
* | ||
* @author Bill Li ([email protected]) [Owner] | ||
* | ||
* @copyright Copyright (c) 2017-2019 Bill Li, Ofcold Institute of Technology. All rights reserved. | ||
*/ | ||
class IdCard implements Rule | ||
{ | ||
/** | ||
* Determine if the validation rule passes. | ||
* | ||
* @param string $attribute | ||
* @param mixed $value | ||
* | ||
* @return bool | ||
*/ | ||
public function passes($attribute, $value) | ||
{ | ||
return IdentityCard::make($value, app()->getLocale()) !== false; | ||
} | ||
|
||
/** | ||
* Get the validation error message. | ||
* | ||
* @return string | ||
*/ | ||
public function message() | ||
{ | ||
return __('Please enter a valid Id Card'); | ||
} | ||
} | ||
|