I use Doctrine and I have a question regarding validation of data set in the entity, should I validate the data before being inserted in the entity or outside it?
/**
* Seta e valida o nome.
* @param string $name
* @param string $input
*/
public function setName(string $name)
{
$this->name = $name;
}
/**
* Seta e valida a senha.
* @param string $pass
* @param string $input
* @depends Validator->Login
* @depends Validator->Pass
* @param type $login - Se true, ele verifica o Validator->Login()
*/
public function setPass(string $pass)
{
$this->pass = $pass;
}
/**
* Seta o endereco manualmente.
* @param string $address
* @param string $input
*/
public function setAddress(string $address)
{
$this->address = $address;
}
/**
* Seta o endereco manualmente.
* @param string $address
* @param string $input
*/
public function setAddress_number(string $address)
{
$this->address_number = $address;
}
/**
* Seta o endereco manualmente.
* @param string $address
* @param string $input
*/
public function setAddress_complement(string $address)
{
$this->address_complement = $address;
}
/**
* Procura o endereco pelo ZipCode e seta o endereco no escopo.
* @param string $address_zipcode
* @param string $input
*/
public function setAddress_zipcode(string $address_zipcode)
{
$this->address_zipcode = $address_zipcode->zipcode;
$this->address_city = $address_zipcode->city;
$this->address_district = $address_zipcode->neighborhood;
$this->address_state = $address_zipcode->state;
$this->address = $address_zipcode->street;
}
/**
* Seta o address state manualmente.
* @param type $address_state
*/
public function setAddress_state($address_state)
{
$this->address_state = $address_state;
}
/**
* Seta o address city manualmente.
* @param type $address_city
*/
public function setAddress_city($address_city)
{
$this->address_city = $address_city;
}