Jump to content

Name validation / Multiple classes for the same purpose


bdesprez

Recommended Posts

Hi,

recently I had some problems about the override of name validation.
I would like to accept digits in customer name.
After some tests, I see it will mby be almost impossible to do it.

The name validation is made at least at 3 different places :

  • PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\CustomerName
  • Validate::isCustomerName (which use Constraints\CustomerName) but could be override
  • PrestaShopBundle\Form\Admin\Sell\Customer\CustomerType (which use Constraints\CustomerName)
  • PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\LastName (which use a specific rule)
  • PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\FirstName (which use a specific rule)

Do you have any idea to accept digits in customer name without rewrite PrestaShop ???
I override Validate::isCustomerName to accept digits, but BO customer form throws an error, so I listen the hook «CustomerFormBuilderModifier» to change the validation rule on firstname and lastname to use the Validate::isCustomerName method (by creating another validator). But now I'm stuck with the validation in PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\LastName and PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\FirstName.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...