Initial Commit
The initial public commit of MVGL website code.
This commit is contained in:
commit
b39ecf1638
2043 changed files with 215154 additions and 0 deletions
32
app/Rules/GameReleaseDates.php
Normal file
32
app/Rules/GameReleaseDates.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use Illuminate\Contracts\Validation\InvokableRule;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class GameReleaseDate implements InvokableRule
|
||||
{
|
||||
/**
|
||||
* Run the validation rule.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail
|
||||
* @return void
|
||||
*/
|
||||
public function __invoke($attribute, $value, $fail)
|
||||
{
|
||||
if ($value === 'TBD' || $value === 'EA') {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
Carbon::createFromFormat('F j, Y', $value);
|
||||
} catch (Exception $e) {
|
||||
$fail('The release date must be in the format of Month Day, Year (ex. March 10, 2000), TBD or EA.');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue