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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:54:46+00:00 2026-06-08T05:54:46+00:00

Hi In my spring webapp I have a password variable which I want to

  • 0

Hi In my spring webapp I have a password variable which I want to be at least 0 characters or more than 6 and less than 20. I know that there is annotation:

 @Size(min=6, max=20)

but I have no idea how to add possibility that password can be 0 characters. Will somebody help me with this?

  • 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-06-08T05:54:48+00:00Added an answer on June 8, 2026 at 5:54 am

    Given the comment, you can use StringTrimmerEditor to convert empty string to null, and then @Size check will not trigger (null is considered as valid in @Size).

    In your controller add following method:

    @InitBinder
    public void initBinder(WebDataBinder binder) {
        binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
    }
    

    Note that StringTrimmerEditor also trims input from spaces, and if you only want one property to be affected by this editor use registerCustomEditor(Class<?> requiredType, String propertyPath, PropertyEditor propertyEditor).

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

Sidebar

Related Questions

I have Apache2 SSL which is fronting Spring webapp as follows: ProxyPass / http://localhost:8080/
Have simple Spring Security webapp with password encoding: <security:authentication-manager alias=authenticationManager> <security:authentication-provider user-service-ref=personService> <security:password-encoder hash=md5
I have a webapp running in Tomcat which uses Spring for dependency injection. (It's
I have a java/spring webapp which uses HibernateTemplate and I was wondering if it
I am writing java/spring webapp in which every user can have its own word
We have a Tapestry-Spring-Hibernate webapp running on Tomcat 6, handing about a few 1000
I have a spring web app that uses Hibernate and Velocity. It's an MVC
I'm using Spring and struts and have the following entry in 'C:/source/webapp/WebContent/META-INF/context.xml' with tokens
(Java Spring WebApp) I have: public class PersonValidator implements Validator { private PersonDAO d;
I've got a fairly standard Spring webapp, and I have a number of custom

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.