Display error with own request class?
I've created an own request class and added two rules for validating google's 2fa.
How can I display error messages?
My ValidateSecretRequest
public function __construct() {
Validator::extend('valid_token', function ($attribute, $value, $parameters, $validator) {
$secret = $this->user->google2fa_secret;
return Google2FA::verifyKey($secret, $value);
}, 'Not a valid token');
Validator::extend('used_token', function ($attribute, $value, $parameters, $validator) {
$key = $this->user->id . ':' . $value;
return !Cache::has($key);
}, 'Used Token');
}```
display it in a view? if so, they should be available in the blade.errors thingy.
@if($errors->has())
@foreach ($errors->all() as $error)
{{ $error }}
@endforeach
@endif
let me know if it's an ajax thingy. I can help there too. it's simple.
Please or to participate in this conversation.