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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:20:58+00:00 2026-05-18T23:20:58+00:00

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’]

  • 0

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']

Then added in src/groovy/Warm.groovy (it’s a non-persistent domain class):

package liningtest

import org.codehaus.groovy.grails.validation.Validateable


class Warm {
  String name;
  int happyCite;

  Warm(String n, int h) {
    this.name = n;
    this.happyCite = h;
  }

  static constraints = {
    name(size: 1..50)
    happyCite(min: 100)
  }
}

But it just doesn’t work (both “blank false” & “size: 0..25”) for the “hasErrors” function. It always returns false, even when the name is > 25.

Is this a Grails bug, if yes, is there any work-around?

I’m using Grails 1.3.3

UPDATE: I have updated the simplified code. And now I know that constraint “size” can’t be used with “blank”, but still does not work.

My test class in test/unit/liningtest/WarmTests.groovy

package liningtest

import grails.test.*

class WarmTests extends GrailsUnitTestCase {
  protected void setUp() {
    super.setUp()
  }

  protected void tearDown() {
    super.tearDown()
  }

  void testSomething() {
    def w = new Warm('Hihi', 3)
    assert (w.happyCite == 3)

    assert (w.hasErrors() == true)
  }
}

And the error I got:

<?xml version="1.0" encoding="UTF-8" ?>
<testsuite errors="1" failures="0" hostname="evolus-50b0002c" name="liningtest.WarmTests" tests="1" time="0.062" timestamp="2010-12-16T04:07:47">
  <properties />
  <testcase classname="liningtest.WarmTests" name="testSomething" time="0.062">
    <error message="No signature of method: liningtest.Warm.hasErrors() is applicable for argument types: () values: []
Possible solutions: hashCode()" type="groovy.lang.MissingMethodException">groovy.lang.MissingMethodException: No signature of method: liningtest.Warm.hasErrors() is applicable for argument types: () values: []
Possible solutions: hashCode()
    at liningtest.WarmTests.testSomething(WarmTests.groovy:18)
</error>
  </testcase>
  <system-out><![CDATA[--Output from testSomething--
]]></system-out>
  <system-err><![CDATA[--Output from testSomething--
]]></system-err>
</testsuite>

UPDATE 2: When I don’t use Unit test, but try to call hasErrors in the controller, it runs but return false value. (hasErrors return false with Warm(‘Hihi’, 3) ). Does anyone has a clue?

UPDATE 3: I followed Victor way, and now the problem is solved if I call validate() before hasErrors(). But I still don’t understand, why “grails generate-all” controllers doesn’t have to call validate() before using hasErrors()?

  • 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-18T23:20:59+00:00Added an answer on May 18, 2026 at 11:20 pm

    You really need to call validate() before – it will trigger validation and change object state. Looking at ValidationGrailsPlugin.addValidationMethods(), I see that hasErrors() is a read-only method.

    Your sample worked for me after calling validate(). I tried in grails console (great tool, I highly recommend it!):

    Warm w = new Warm('')
    w.hasErrors() // 'Result: false'
    w.validate()
    w.hasErrors() // 'Result: true'
    

    I added @Validateable to Warm class. I believe it makes no difference.

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

Sidebar

Related Questions

Is this possible? I've followed the instructions from here ( http://www.jetbrains.net/confluence/display/TCD4/Setting+up+an+External+Database#SettingupanExternalDatabase-MicrosoftSQLServer2005 ) but I
I followed these instructions here: http://logback.qos.ch/consolePlugin.html I have the correct and found logback.xml, it
I'm using compiled OpenSSL for an iPhone app. I followed the instructions here http://www.x2on.de/kontakt/
Admob code can't see on device. I followed the instructions here: http://www.admob.com/docs/AdMob_Android_SDK_Instructions.pdf everything ok,
I have followed all the instructions here: http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/ to install & config apache get
I've followed the instructions here: http://xach.livejournal.com/278047.html and gotten them to work. I called the
i'm trying to create a horizontal layout following this guide here: http://www.queness.com/post/356/create-a-vertical-horizontal-and-diagonal-sliding-content-website-with-jquery Now it
I followed the instructions here: http://developer.android.com/sdk/eclipse-adt.html#installing but the installation froze, so I stopped it
I followed the instructions here http://support.microsoft.com/kb/825532 After that when I preview my page, I
I have followed the instructions here: http://help.github.com/win-set-up-git/ to set up git on my windows

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.