Skip to content

Instantly share code, notes, and snippets.

@hanspagel
Created December 8, 2017 14:25
Show Gist options
  • Save hanspagel/5051a85f2790873ef17c2d68c08caad4 to your computer and use it in GitHub Desktop.
Save hanspagel/5051a85f2790873ef17c2d68c08caad4 to your computer and use it in GitHub Desktop.
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class UuidRule implements Rule
{
public function passes($attribute, $value)
{
return preg_match("/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/", $value);
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return 'Invalid Uuid.';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment