OSDN Git Service

=alphaNumeric()の上書き
authorcake_67 <cake_67@46fa8b77-3530-0410-9d82-d95c44d28aba>
Wed, 25 Nov 2009 08:05:01 +0000 (08:05 +0000)
committercake_67 <cake_67@46fa8b77-3530-0410-9d82-d95c44d28aba>
Wed, 25 Nov 2009 08:05:01 +0000 (08:05 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/trpgtools-onweb/src/trunk/members_framework/cakePHP_frame@134 46fa8b77-3530-0410-9d82-d95c44d28aba

app/models/app_model.php
app/models/user.php

index cf087f3..d313b85 100644 (file)
@@ -4,13 +4,25 @@ class AppModel extends Model {
 
        function beforeValidate(){
                $error_messages = array(
-                       'notempty'      => __('Please be sure to input.'),
-                       'between' => __('Between %2$d and %3$d characters.',true),
+                       'notEmpty'      => __('Please be sure to input.', true),
+                       'between' => __('Between %2$d and %3$d characters.', true),
+                       'alphaNumeric' => __('Please input only alphameric characters.',true),
                );
                $this->setErrorMessageI18n($error_messages, false);
 
                $this->replaceValidationErrorMessagesI18n();
                return true;
        }
+
+       /* 本線alphaNumeric()の上書き */
+       function alphaNumeric($data) {
+               $check = is_array($data) ? array_shift($data) : $data;
+               if (preg_match('/^[0-9a-z]+$/i',$check)) {
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
 }
 
index 5a92f81..8dd0a10 100644 (file)
@@ -5,17 +5,26 @@ class User extends AppModel {
 
        var $validate = array(
                'username' => array(
-                       'notempty' => array(
+                       'alphaNumeric' => array(
+                               'rule' => 'alphaNumeric',
+                       ),
+                       'notEmpty' => array(
                                'rule' => 'notEmpty',
                        ),
                ),
                'password1' => array(
-                       'notempty' => array(
+                       'alphaNumeric' => array(
+                               'rule' => 'alphaNumeric',
+                       ),
+                       'notEmpty' => array(
                                'rule' => 'notEmpty',
                        ),
                ),
                'password2' => array(
-                       'notempty' => array(
+                       'alphaNumeric' => array(
+                               'rule' => 'alphaNumeric',
+                       ),
+                       'notEmpty' => array(
                                'rule' => 'notEmpty',
                        ),
                )