Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1015835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:27:35+00:00 2026-05-16T10:27:35+00:00

When I save the information from a registration form I have some validation rules

  • 0

When I save the information from a registration form I have some validation rules on the username and email fields (I’ve pasted the rules below). Validation is called automatically with the saveAll() function.

The problem is that the isUnique rule on the username field doesn’t work at all (doesn’t return any error). The other rules for this field work just fine, and the unique validation for the email field also works. I can’t seem to figure out why this is happening, when the two rules are basically the same.

var $validate = array(

    'username' => array(

        'isUnique' => array (

            'rule' => 'isUnique',

            'message' => 'This username already exists.'),

        'custom' => array (

            'rule' => array('custom', '/^[A-Za-z0-9,\.-_]*$/i'), 

            'message' => 'The username can only contain letters, numbers, _, - and .'),

        'minLength' => array(

            'rule' => VALID_NOT_EMPTY,

            'message' => 'You must fill in the username.')          
    ),

    'email' => array(

        'isUnique' => array (

            'rule' => 'isUnique',

            'message' => 'This email address already exists in our database.'),

        'valid' => array (

            'rule' => array('email', false),

            'message' => 'Invalid email.'),

        'minLength' => array(

            'rule' => VALID_NOT_EMPTY,

             'message' => 'You must fill in the email address.')

    )

);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:27:36+00:00Added an answer on May 16, 2026 at 10:27 am

    The “isUnique” rule looks for repeating values in other rows. Which will create a problem if the “isUnique” test is also the primary key. So, based on your rules/model above, if you look at the SQL dump when the rule is run, you will likely see something like

    SELECT COUNT(*) FROM users WHERE username = 'x' AND username != 'x'
    

    This obviously returns 0 or “unique” in the test. Fix would be to set the primary key equal to something other than the field you are testing the rule on. When you do that, the SQL dump should show something like

    SELECT COUNT(*) FROM users WHERE username = 'x' AND key != 'y'
    

    This will return the >0 when the field is not unique and the desired functionality will be restored.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application I have a button to save some information. However, I would
I'm trying to save some information from a user that is saved on the
i am getting some information from .net webserver and save them in NSuserdefaults. for
I'm looking to save some information from a ListView to a file and was
I have a form that collects information from several models that are several layers
I am building an application where the user can save some information into an
I'm building an installer using InstallScript MSI project. During installation I save some information
My application uses MS access database to save some sensitive information. Though that information
I have a CSV export script (enrdata_arch.php) which calls information from an existing database
I am parsing some vertice information from an XML file which reads as follows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.