Replies: 1 comment
-
it('tt', function (){
class Nested extends Data{
#[StringType, Required, Password]
#[MapName('user_password')]
public string $password;
#[StringType, Required, Same('user_password')]
#[MapName('user_password_confirmation')]
public string $passwordConfirmation;
}
class Main extends Data{
public Nested $user;
}
dd(Main::validateAndCreate([
'user' => [
'user_password' => 'hieriseengrotetest',
'user_password_confirmation' => 'hieriseengrotetest',
]
]));
}); This will be fixed in the version released later today. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello
We have a CreateUserDto that has 2 properties
In the UserDto, we are using the rule
Same()
as an attribute to check if the password confirmation is the same as the password#[StringType, Required, Password]
#[MapOutputName('user_password')]
public string $password = '',
#[StringType, Required, Same('password')]
#[MapOutputName('user_password_confirmation')]
public string $passwordConfirmation = '',
We keep getting an error that
user.password
is not the same asuser.passwordConfirmation
If we change the value in the
Same()
rule to beuser.password
, it works.However, now, we cannot use UserDto as a standalone DTO.
The DTO is validated at the controller by the depedency injection:
public function createUser(UserCreateDto $request): Response
{
return ResponseApiFacade::created(
new UserResource(
(new UserCreateService())->create($request->toArray())
)
);
}
Any idea on how to get around that issue ?
Beta Was this translation helpful? Give feedback.
All reactions