title: cakephp: model validation rules, form field, ===
body: <p>After studying Miles Jones cupcake forum plugin, I have a couple of questions here:</p>
  
  <p>1)Is it compulsory for each field (that appears in a model's validation rules) to be a field in a database table? I found the following validation rules in the User model of cupcake forum plugin. oldPassword and newPassword are not fields in the users table. I'm confused coz' I thought I should only make validation rules for fields of table.</p>
  
  <pre><code>public $validate = array(
      'username' =&gt; array(
          'isUnique' =&gt; array(
              'rule' =&gt; 'isUnique',
              'message' =&gt; 'That username has already been taken',
              'on' =&gt; 'create'
          ),
          'notEmpty' =&gt; array(
              'rule' =&gt; 'notEmpty',
              'message' =&gt; 'Please enter a username'
          )
      ),
      'password' =&gt; array(
          'rule' =&gt; 'notEmpty',
          'message' =&gt; 'Please enter a password'
      ),
      'oldPassword' =&gt; array(
          'rule' =&gt; array('isPassword'),
          'message' =&gt; 'The old password did not match'
      ),
      'newPassword' =&gt; array(
          'isMatch' =&gt; array(
              'rule' =&gt; array('isMatch', 'confirmPassword'),
              'message' =&gt; 'The passwords did not match'
          ),
          'custom' =&gt; array(
              'rule' =&gt; array('custom', '/^[-_a-zA-Z0-9]+$/'),
              'message' =&gt; 'Your password may only be alphanumeric'
          ),
          'between' =&gt; array(
              'rule' =&gt; array('between', 6, 20),
              'message' =&gt; 'Your password must be 6-20 characters in length'
          ),
          'notEmpty' =&gt; array(
              'rule' =&gt; 'notEmpty',
              'message' =&gt; 'Please enter a password'
          )
      ),
      'email' =&gt; array(
          'isUnique' =&gt; array(
              'rule' =&gt; 'isUnique',
              'message' =&gt; 'That email has already been taken',
              'on' =&gt; 'create'
          ),
          'email' =&gt; array(
              //'rule' =&gt; array('email', true),//boolean true as second parameter verifies that the host for the address is valid -- to be uncommented once website is uploaded
              'rule' =&gt; array('email'),
              'message' =&gt; 'Your email is invalid'
          ),
          'notEmpty' =&gt; array(
              'rule' =&gt; 'notEmpty',
              'message' =&gt; 'Your email is required'
          )
      )
  );
  </code></pre>
  
  <p>2)Does each form field need to be a field in a database table?</p>
  
  <p>For example when I ask a user to signup there will be: username, email addr, password and confirm password. But confirm password field doesn't need to be a field in a table right?
  Is that a good practice?</p>
  
  <p>I found the following isMatch function in form_app_model.php:</p>
  
  <pre><code>/**
   * Validates two inputs against each other
   * @access public
   * @param array $data
   * @param string $confirmField
   * @return boolean
   */
  public function isMatch($data, $confirmField) {
      $data = array_values($data);
      $var1 = $data[0];
      $var2 = (isset($this-&gt;data[$this-&gt;name][$confirmField])) ? $this-&gt;data[$this-&gt;name][$confirmField] : '';
  
      return ($var1 === $var2);
  }
  </code></pre>
  
  <p>Can someone tell me on what is === in the last line of the above code?</p>
  
  <p>Thank you.</p>