i have a question regarding symfony 2 validation via an Entity and a validation configuration file. Here is the explanation of the problem.
I have an entity for the users account settings which has 5 properties - subdomain, email, oldPassword, password and new_password_confirmed.
My configuration file is as follows:
Backend\Builders\PageBundle\Entity\AccountSettings:
properties:
email:
- Email: ~
oldPassword:
- Symfony\Component\Security\Core\Validator\Constraints\UserPassword:
message: "Wrong value for your current password"
constraints:
- Expression:
expression: "this.passwordMatch()"
message: "Passwords don`t match"
My question is - How can i use this entity for validation and choose to perfom the validation only on a certain item, for example the email . Here is my code in the moment for this validation, but it requires all the validation rules to be met in order the validation to be successfull:
$accountSettings = new AccountSettings();
$accountSettings->email = $_POST['email'];
$validator = $this->get('validator');
$errors = $validator->validate($accountSettings);