0

I would like an advice. I work on Symfony 4.

I need to check in my controller if the password got an uppercase letter, a number, a special character and if the length is 8 characters minimum. I already do the checking in my twig by adding the regex in the attribute of the input.

I don't know if I must take the string and check for each letter.

Do you know a better way to do it?

Thanks.

0

1 Answer 1

1

You can use annotations to define the validation of an entity property.

use Symfony\Component\Validator\Constraints as Assert;

// I assume your entity is named Users
class Users
{
    // some properties

    /*
     * @Assert\Regex(pattern = "/Your RegEx goes there/",
     *               message = "Your nice error message")
     */
    private $password;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.