If you want further control, you can also use regex. Here's how I have my
usernames set up (a bit more involved, but much finer control)
'username' => array(
'alphanumeric' => array(
'rule' => array('custom', '/[a-z0-9\_\-\.]$/i'),
'required' => true,
'message' => 'Username must be a-z, 0-9, plus "_",
"-", " ", "."'
),
'between' => array(
'rule' => array('between', 5, 30),
'message' => 'Between 5 and 30 characters'
),
'checkUnique' => array(
'rule' => 'isUnique',
'message' => 'Username is in use. Choose another.'
)
)
The way this works, the username must be A) Unique, B) between 5 and 30
characters, and C) of the characters A-Z, a-z, 0-9, plus space ' ', hyphen
'-', underscore '_', and period '.'
I'll gladly explain this further if anyone wants to know anything else :-D
In the name of Life, Liberty, and the pursuit of my sanity.
Siebren Bakker(Aevum Decessus)
On Thu, Jun 12, 2008 at 02:29, Reza Muhammad <[EMAIL PROTECTED]> wrote:
>
> Well, of course, here's what I had before:
>
> var $validate = array(
> 'passwd' => array(
> 'rule' => VALID_NOT_EMPTY,
> 'message' => 'Username cannot be blank'
> )
> ));
>
> and here's what I have now:
>
> var $validate = array('username' => array(
> 'notempty' => array(
> 'rule' => VALID_NOT_EMPTY,
> 'message' => 'Username cannot be blank'
>
> ),
> 'unique' => array(
> 'rule' => 'isUnique',
> 'message' => 'Username existed. Choose
> another one'
> )
> ));
>
> Thanks for the help :)
>
> On Jun 11, 2008, at 11:44 PM, 703designs wrote:
>
> >
> > What did you change it to?
> > I think it's always a good idea to follow up with your solution so
> > that others can learn from your experiences.
> >
> > On Jun 11, 6:22 am, Reza Muhammad <[EMAIL PROTECTED]> wrote:
> >> Thanks Grant. Yeah, it turned out that i only needed to change my
> >> validation rule.
> >>
> >> Good day.
> >> Reza
> >> On Jun 11, 2008, at 11:59 AM, Grant Cox wrote:
> >>
> >>
> >>
> >>> There is no such limit in Cake by default, it'll be in your
> >>> application code.
> >>
> >>> Are you sure that the model is passing validation? If you have the
> >>> "alphaNumeric" validation rule, it'll fail on a period, as it
> >>> explicitly only allows alphabetic and numeric chars. What is the
> >>> SQL
> >>> being generated?
> >>
> >>> Please post your relevant model and controller action if you require
> >>> further assistance.
> >>
> >>> On Jun 11, 2:50 pm, Reza Muhammad <[EMAIL PROTECTED]> wrote:
> >>>> Hi all,
> >>
> >>>> I just noticed that by default Cake wouldn't save data where a .
> >>>> (dot)
> >>>> is present. For example, I tried to add a new username that is
> >>>> "firstname.lastname", and Cake said that the user was added
> >>>> successfully, but it wasn't added at all.
> >>
> >>>> What do I need to add so that Cake can accept this type of special
> >>>> character? Is sanitize part of it?
> >>
> >>>> Thank you.
> > >
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---