Mejoras en la api
This commit is contained in:
@@ -3,10 +3,17 @@
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use App\Exceptions\InvalidUuidException;
|
||||
|
||||
class UuidService extends ServiceProvider {
|
||||
public function is_valid(string $uuid) {
|
||||
public function isValid(string $uuid) {
|
||||
$regex = '/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i';
|
||||
return preg_match($regex, $uuid) === 1;
|
||||
}
|
||||
|
||||
public function validOrFail(string $uuid) {
|
||||
if(!$this->isValid($uuid)) {
|
||||
throw new InvalidUuidException($uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user