0
votes

I am trying to amend my validation in my Model.

I need to check to see if (FIELD1 and FIELD2) are unique. For example

FIELD1 = "mattfacer" //username FIELD2 = "1192" //chosen display ID

I need to check the database to see if the FIELD1 and FIELD2 have been used. If not, it should pass validation. If that display ID of 1192 and the username "mattfacer" has been used, return false for validation.

Is that possible? I was thinking of a custom validation function but not sure where I'd call it?

Thank you.

[edit] The username and display ID are not unique in them selves.. it's the combination of the two which need to be unique. So there could be the following which is allowed

username = mattfacer displayid = 6609

username = suziefacer displayid = 6609

Those would be allowed.

[/edit]

1
Check out Validate Uniqueness.mark

1 Answers

0
votes
// you may be use this 
<?php
 public $validate = array('FIELD1' => array('beta' => array(
                                            'rule' => 'isUnique',
                                            'message' => 'This FIELD1 alreay exists!',
                                         )),
     'FIELD2'=> array('beta' => array(
                                            'rule' => 'isUnique',
                                            'message' => 'This FIELD2 alreay exists!',
                                         )
                        );
?>