Skip to content

Instantly share code, notes, and snippets.

@dai199
Last active June 18, 2018 16:19
Show Gist options
  • Select an option

  • Save dai199/4661224 to your computer and use it in GitHub Desktop.

Select an option

Save dai199/4661224 to your computer and use it in GitHub Desktop.
CakePHP2 パスワードを2回入力させて同じものであればtrueを、違うものであればfalseを返す
<?php
class User extends AppModel {
public $validate = array(
'password' => array(
'rule' => array('between', 3, 10),
'message' => 'Between 3 to 10 characters'
),
'password_confirm' => array(
'rule' => array('passwordCheck'),
'message' => 'Confirm password again'
)
);
public function passwordCheck(){
if($this->data[$this->alias]['password'] === $this->data[$this->alias]['password_confirm']){
return true;
} else {
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment