this should work in theory - local is screwy though

This commit is contained in:
spencerrlongg
2024-11-13 21:38:09 -06:00
parent 4841b89109
commit 3982201d0e
4 changed files with 82 additions and 12 deletions
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Rules;
use Closure;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Support\Facades\Crypt;
class NumericEncrypted implements ValidationRule
{
/**
* Run the validation rule.
*
* @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
try {
$value = Crypt::decrypt($value);
if (!is_numeric($value)) {
$fail($attribute.' is not numeric.');
}
} catch (\Exception $e) {
$fail($e->getMessage());
}
}
}