Skip to content

Instantly share code, notes, and snippets.

@blood72
Created February 19, 2020 05:57
Show Gist options
  • Select an option

  • Save blood72/4a93556723f48857558ec704d549a1af to your computer and use it in GitHub Desktop.

Select an option

Save blood72/4a93556723f48857558ec704d549a1af to your computer and use it in GitHub Desktop.
IsEncrypted.php
<?php
use Illuminate\Support\Facades\Validator;
Validator::extend('encrypted', function ($attribute, $value, $parameters, $validator) {
try {
return decrypt($value);
} catch (\Illuminate\Contracts\Encryption\DecryptException $exception) {
return false;
}
});
@blood72
Copy link
Copy Markdown
Author

blood72 commented Feb 19, 2020

// resources/lang/en/validation.php
'encrypted' => 'The :attribute is invalid.',

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment