<?php
App::uses('AppModel', 'Model');
/**
 * ContactValidate Model
 *
 */
class ContactValidate extends AppModel {

	public $useTable = false;
	public $name = 'ContactValidate';

	public $_schema = array(
		'name' => array(
			'type' => 'string',
			'length' => 128,
		),
		'mail' => array(
			'type' => 'string',
			'length' => 255,
		),
		'comment' => array(
			'type' => 'string',
			'length' => 255,
		),
	);

/**
 * Validation rules
 * 
 * @var array
 */
	public $validate = array(
		'name' => array(
				'rule' => array('notBlank'),
                'message' => 'この項目は入力必須です'
		),
        'email' => array(
        	array(
				'rule' => array('notBlank'),
                'message' => 'メールアドレスを入力してください'
            ),
            // メールアドレスであること。
            'isEmail' => array( 
				'rule' => 'Email',
            	'message' => '正しいメールアドレスを入力してください'
            ),
            array(
                'rule' => 'emailConfirm', 
                'message' => 'メールアドレスが一致していません'
            ), 
        ),
        'email_confirm' => array(
            array(
				'rule' => array('notBlank'),
                'message' => 'メールアドレス(確認)を入力してください'
            ), 
        ),

        'comment' => array(
			'notblank' => array(
				'rule' => array('notblank'),
				'message' => '入力されていません',
			),
		),
	);


    public function emailConfirm($check){
        //２つのパスワードフィールドが一致する事を確認する
        if($this->data['ContactValidate']['email'] === $this->data['ContactValidate']['email_confirm']){
            return true;
        }else{
            return false;
        }

    }


}
