Commit 781c1d5a authored by Mat's avatar Mat
Browse files

contraintes email et tva

parent f132a6de
......@@ -4,12 +4,17 @@ namespace AssoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* Association
*
* @ORM\Table(name="association")
* @ORM\Entity(repositoryClass="AssoBundle\Repository\AssociationRepository")
* @UniqueEntity(
* fields="email",
* message="L'adresse {{ value }} est déjà utilisée"
* )
*/
class Association
{
......@@ -62,7 +67,7 @@ class Association
* maxMessage = "Le champs doit contenir au maximum {{ limit }} caractères"
* )
* @Assert\Email(
* message = "The email '{{ value }}' is not a valid email.",
* message = "L'adresse mail {{ value }} n'est pas valide",
* checkMX = true
* )
*/
......@@ -79,7 +84,7 @@ class Association
* maxMessage = "Le champs doit contenir au maximum {{ limit }} caractères"
* )
* @Assert\Regex(
* pattern="/^(?:|BE|BE |BE-)(0[0-9]{3})(?:| |-)([0-9]{3})(?:| |-)([0-9]{3})$/",
* pattern="/^(?:|BE|BE |BE-|BE.)(0[0-9]{3})(?:| |-|.)([0-9]{3})(?:| |-|.)([0-9]{3})$/",
* match=true,
* message="Le n° de TVA n'est pas correctement formaté"
* )
......@@ -195,7 +200,11 @@ class Association
*/
public function setTva($tva)
{
$this->tva = $tva;
$re = '/^(?:|BE|BE |BE-|BE.)(0[0-9]{3})(?:| |-|.)([0-9]{3})(?:| |-|.)([0-9]{3})$/';
$subst = 'BE \\1 \\2 \\3';
$result = preg_replace($re, $subst, $tva, 1);
$this->tva = $result;
return $this;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment