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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:12:39+00:00 2026-05-13T20:12:39+00:00

I am trying to figure out how to use Validation on Business Objects. Until

  • 0

I am trying to figure out how to use Validation on Business Objects.

Until now I have only seen examples on CustomValidator that checks for only 1 error. I have two fields with DateTime input that should check for 3 or more errors. I guess normally I should check on client, then on server, last on database level.

  • If I get an error on a field, I should not be able to leave the field.
  • On the Client Validation this is not an error that should cause an Exception since it’s only a user error. But if something goes wrong and the user bypass the Client Validation, the Server Validation should kick an Exception.
  • And last, if i have other e.g. Batch Update work then they should use the Database Validation code. Please correct me if I have missed something fundamental!
  1. `dateFrom` is not empty. (But `dateTo`can be empty)
  2. `dateFrom` is earlier than `dateTo`
  3. `dateFrom` and `dateTo` is within constant `MinDate` and `MaxDate`

So How should my Validation look like, Client, Server and Database?

Thoughts:

Should the validation logic be separated on 3 different places; UI, Code and DataObject(Database)? When it is the exact same code? Seems redundant?

Can I use the same validation method for all three checks? Or do I need to implement 3 code-chunks, and 3 Methods for each, and then how do I list all in the ValidationSummary nicely?

  • 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-13T20:12:39+00:00Added an answer on May 13, 2026 at 8:12 pm

    To reduce code duplication and the errors resulting from it, all validation code should be in a single layer – preferably the business layer, as it is in the best position to evaluate the object and determine if it is valid or not.

    However, while that is a theoretical ideal, it is often not pragmatic in real world situations. In a client-server environment, like ASP.NET, you want to duplicate as much of the validation as possible on the client side, in order to reduce round trips to the server. Also, if you have other business procedures (such as batch uploads) that touch your table without going through your business object, you will need to implement the validation in the database as well, to prevent garbage data from being created.

    For validation like in your example, I would create three validation methods on my business object and three CustomValidators – each validator would call the corresponding method on the business object on the server side. I would also code up some JavaScript to run on the client side, so the server side code would just exist to catch non-JavaScript enabled browsers, or maliciously crafted HTTP requests.

    For validation that is difficult to do in JavaScript (i.e. requires the business object), I will not bother with a CustomValidator. Instead, those validations wait until the user presses the submit button, at which point I can use the business object to validate itself and return any errors.

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

Sidebar

Related Questions

I've been having a lot of problems trying to figure out how to use
I'm new to Rails development, and I'm trying to figure out how to use
I'm trying to figure out how to decide when to use NSDictionary or NSCoder/NSCoding?
I'm fairly new to C++ and an trying to figure out to use the
I am trying to figure out how to use proxy classes in Django. I
I'm trying to figure out how to use JQuery to display some tools when
I'm trying to figure out what to use for my web application. Im currently
I am trying to figure out how to use/create a custom control in ASP.NET
Ruby newbie here trying to figure out how to use a Gem and thus
Trying to figure out an equation to get the current group a page would

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.