8 Replies Latest reply on Nov 30, 2007 9:37 AM by pmuir

    Modifying Hibernate validator msgs

    trippccn

      1) Is there a way to override Hibernates DefaultValidatorMessages.properties file so that I can have custom messages without actually changing the properties file inside hibernate-annotations.jar?

      2) The @NotNull validator only checks for Null but not empty strings (eg. empty form field)... obviously this is intended, but is there a way to check for empty strings? Should I use @Pattern?

      Thanks,
      Chad

        • 1. Re: Modifying Hibernate validator msgs
          patrick_ibg

          On #2, use a @Length (min = 1) validator.

          • 2. Re: Modifying Hibernate validator msgs
            epbernard

            Hi,
            For #1, read theHibernate Annotations reference documentation, chapter 3.1.3
            Basically you can create a ValidatorMessages.properties or ValidatorMessages_fr.properties and put it in your classpath root

            patrick is right @Length will be faster than a regexp

            • 3. Re: Modifying Hibernate validator msgs
              trippccn


              Hey guys thanks for your replies.

              Cool I'll use length instead. The only reason I didn't do that was so that I wouldn't have to override the length message which I feel should be diff from an empty value... no biggie.

              Ya I read the hibernate docs, and it seems simple, but I couldn't get the ValidatorMessages.properties to work. They were in my classpath at compile time, is there anything else I need to do? The docs don't give any examples.

              Thanks again,
              Chad

              • 4. Re: Modifying Hibernate validator msgs
                ohadpinchevsky

                 

                "TrippCCN" wrote:

                Hey guys thanks for your replies.

                Cool I'll use length instead. The only reason I didn't do that was so that I wouldn't have to override the length message which I feel should be diff from an empty value... no biggie.

                Ya I read the hibernate docs, and it seems simple, but I couldn't get the ValidatorMessages.properties to work. They were in my classpath at compile time, is there anything else I need to do? The docs don't give any examples.

                Thanks again,
                Chad


                Hi Chad.

                I have the same problem with ValidatorMessages.properties, did you find out what it was?

                10x,
                Ohad

                • 5. Re: Modifying Hibernate validator msgs
                  dahm

                  Hi,

                  I had the same problems using my ValidatorMessages.properties
                  I put it in anywhere in my JAR and EJB3 archives, but it didn't work.
                  It seems to be a classloader problem. If you modify the
                  DefaultValidatorMessages.properties file in the hibernate-annotations.jar
                  in the ejb3.deployer folder it works. Yet this is ugly and not feasible
                  for deployment.

                  As a quick workaround I put my ValidatorMessages.properties in
                  separate JAR and copied that into the ejb3.deploy folder. However,
                  you'll have to restart the server.

                  I guess this needs to be fixed by the Hibernate guys...?

                  Cheers
                  Markus

                  P.S. I'm using SEAM

                  • 6. Re: Modifying Hibernate validator msgs
                    epbernard

                    I did have a bug regarding the way ValidatorMessages was loaded. This will be fixed in the next release.

                    • 7. Re: Modifying Hibernate validator msgs
                      jcelano

                      has this been fixed? I am noticing the same issue using Seam 2.0 GA with Jboss 4.2

                      • 8. Re: Modifying Hibernate validator msgs
                        pmuir

                        Yes. Start a new topic with your issue.