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 6554703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:43:52+00:00 2026-05-25T12:43:52+00:00

http://www.grails.org/doc/latest/ref/Constraints/validator.html I have a project where I would like users to log in with

  • 0

http://www.grails.org/doc/latest/ref/Constraints/validator.html

I have a project where I would like users to log in with a temporary password I provide them via SMS message. Thus, on login I would like to use the custom validator to check against the password I have created using a Java class.

class LoginCommand {

    String telephoneNumber;  /* the users telephone number, used for logging in */
    String password;         /* the password they entered, must match the generated pw below */

    /* the generated password, which has been sent to the user via SMS */
    String generatedPassword = PasswordGenerator.passwordGenerator(telephoneNumber)

    def jsecSecurityManager

    boolean authenticate() {
        def authToken = new UsernamePasswordToken(telephoneNumber, password)
        try {
            this.jsecSecurityManager.login(authToken)
            return true
        } catch (AuthenticationException ae) {
            return false
        }
    }

    static constraints = {
        telephoneNumber     blank:false
        password            blank:false

        /* the problem lies here, I need to pass that generatedPassword as an argument to the validator here, however I have no idea how to do that */
        password(validator: {
                if (!it.startsWith(generatedPassword)) return ['invalid.password']
        })
    }

}
  • 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-25T12:43:53+00:00Added an answer on May 25, 2026 at 12:43 pm

    The validator constraint takes an argument for the object being validated:

    validator: { val, obj ->
        if(!val.startsWith(obj.generatedPassword)) ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I followed the instruction here: http://www.grails.org/doc/latest/guide/7.%20Validation.html and added into config.groovy : grails.validateable.classes = [liningtest.Warm']
I have read the documentation for Grails and Webtest in this site: http://www.grails.org/plugin/webtest And
I'm doing a groovy/grails form file-upload operation, as is described here http://www.grails.org/File+Upload I'd like
i have a grails application and i'm following the tutorial here: http://www.grails.org/Services i have
http://www.interact-sw.co.uk/iangblog/2004/04/26/yetmoretimedlocking Why is this line needed? System.GC.SuppressFinalize(tl.leakDetector); I would have thought the finalizer should
The closest-related implementation in Haskell I have seen is the forward mode at http://hackage.haskell.org/packages/archive/fad/1.0/doc/html/Numeric-FAD.html
http://www.grails.org/1.3.1+Release+Notes Improved Query Caching The findAll query method now supports taking advantage of the
Why Grails see URLs without http:// (like www.google.com) as invalid? Only http://google.com and http://www.google.com
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html According to that article STL isn't suited for game-development. What are your thoughts
I've added plugin calendar http://www.grails.org/plugin/calendar to my web app. I don't know how to

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.