I am trying to add a validation rule to my Model in CakePHP to check that an ip address is unique. The problem is that I am saving the ip address in my database as an unsigned int, but the user is entering it as a string. To do this I am using a beforeSave function that changes the ip address to the int value that will be saved. Is there a way to make the isUnique rule run after the beforeSave function? Currently my validation rules look like this.
public $validate = array(
'ip_address' => array(
'notEmpty' => array(
'rule' => 'notEmpty',
'message' => 'You must enter an IP address'
),
'unique' => array(
'rule' => 'isUnique',
'required' => 'create',
'message' => 'This IP address already exists'
)
)
);