$definition =
new DataValidationDefinition('customer.password.update'
);
$minPasswordLength =
$this->systemConfigService->
get('core.loginRegistration.passwordMinLength',
$context->
getSalesChannel()->
getId());
$definition->
add('newPassword',
new NotBlank(),
new Length(['min' =>
$minPasswordLength]),
new EqualTo(['propertyPath' => 'newPasswordConfirm'
]));
$this->
dispatchValidationEvent($definition,
$data,
$context->
getContext());
$this->validator->
validate($data->
all(),
$definition);
$this->
tryValidateEqualtoConstraint($data->
all(), 'newPassword',
$definition);
} private function dispatchValidationEvent(DataValidationDefinition
$definition, DataBag
$data, Context
$context): void
{ $validationEvent =
new BuildValidationEvent($definition,
$data,
$context);
$this->eventDispatcher->
dispatch($validationEvent,
$validationEvent->
getName());
} /**
* @param array<string|int, string> $data
*
* @throws ConstraintViolationException
*/