I want to allow users to leave the email and phone blank on the register function. I also want any added emails or phones no. to be unique. However the isUnique function in the build rules is stopping this because it sees that the blank field already exists.
public function buildRules(RulesChecker $rules)
{
$rules->add($rules->isUnique(['username']));
$rules->add($rules->isUnique(['email']));
$rules->add($rules->isUnique(['phone']));
return $rules;
}
How can I remedy this? I have already tried the ->allowEmpty in the validation but it doesn't work. There is nothing about this in the documents. As specific as this.
NULLusing ordinary comparision operators (which the unique rule does) should always beNULL(AFAIK this is at least the case in MySQL and Postgres), thus nothing being found, and consequently the unique check should pass. Reyling on this behavior is kinda ugly though, so this might be worth an enhancement for the core. Anyways, which DBMS are you using? What does the tablesCREATE TABLEstatement look like? And what does the data that you are trying to save look like? - ndm