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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:43:03+00:00 2026-06-10T05:43:03+00:00

I was working on apache commons validator latest. Problem explained below. My Bean is

  • 0

I was working on apache commons validator latest. Problem explained below.

My Bean is having 2 properties fullName (String) & age (int). Validation “required” on both but age needed to be checked for “integer” as well.

bean.setFullName("Tester"); -----> Will Pass
bean.setAge("Too Old"); ---> "required Pass but "integer" Fail.

results = validator.validate();

Note: Above is possible if age property is String but its not and setAge won’t accept String value and throw exception before reaching validator.validate().

Validation should be checked before we set the bean. In above situation I need to make all properties string than in validation.xml check for integer/condition.

How I work with this when my age property is Integer. little confused. Handle bean with date, integer etc?

  • 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-10T05:43:04+00:00Added an answer on June 10, 2026 at 5:43 am

    My Bean is having 2 properties fullName (String) & age (int). Validation “required” on both but age needed to be checked for “integer” as well.

    If your domain class declares age already to be an int then you have two options

    1. Check the data before you call setAge(int a) and you can use the IntegerValidator
    2. Provide a overloaded method setAge(String a) which internall uses IntegerValidator

    My recommendation

    commons-validator only works on strings (if you want your entire bean to be validated at once) and isn’t a fit for your scenario. I suggest you dump that in favor of the standard JSR 303. It is rich in functionality and has a two very good implementations:

    1. Hibernate Validator
    2. Apache BVAL
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a working prototype of a Java application that is using Apache Commons
I am using Apache Commons File Uploader API. It is working successfully when I
I'm working with Apache's FTPClient class in the Apache commons net library. Sadly it
I've a Java app, working with Lucene and Apache commons Digester to parse a
what I have: an external GroovyScript using the apache-commons-io library and a working grails
I am trying to run mathtext from a java program using apache-commons-exec. The problem
I'm working on an Apache Wicket project in Eclipse with Maven2 -- my SCM
I'm working with the Apache Thrift tool and i'm throwing some Exceptions from the
I've been working with the Apache Mahout machine learning libaries in my free time
I have a working WAMP environment (Apache Friends). I decided to try Subversion and

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.