-
Hey folks, is it possible to disable validation when using Since we're injecting the user property, I don't really think validation needs to run on this property, right? <?php
namespace App\Domains\Users\Data;
use Spatie\LaravelData\Attributes\FromAuthenticatedUser;
use Spatie\LaravelData\Data;
class TeamCreateData extends Data
{
#[FromAuthenticatedUser]
public UserData $user;
public function __construct(
public readonly string $name,
) {}
public static function rules(): array
{
return [
'name' => 'required|min:5|max:255|unique:teams',
'user' => '', // without this line, validation fails
];
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
ellisio
Feb 19, 2025
Replies: 1 comment
-
I found it, but perhaps this should be inherited behavior. The following allows me to omit the empty #[WithoutValidation]
#[FromAuthenticatedUser]
public UserData $user; |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ellisio
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found it, but perhaps this should be inherited behavior. The following allows me to omit the empty
user
rules.