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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:59:04+00:00 2026-05-23T08:59:04+00:00

I am currently refactoring my project and one thing I’m not quite sure on

  • 0

I am currently refactoring my project and one thing I’m not quite sure on is how to handle business validation errors.

At the moment I am using the RulesException class from the xVal library, I beleive this library is no longer being developed so I probably need to update my code accordingly…here is an example of one of my methods on a domain model:

 public virtual void AddComment(ProfileComment comment)
        {
            // ensure account is active before sending a message
            if (comment.FromAccount.AccountStatus != Enums.Common.AccountStatus.Active) throw new RulesException("", "Your account is not active");

            // throw exception if user has blocked this user
            if (HasUserBeenBlocked(comment.FromAccount)) throw new RulesException("", "User has blocked this action being performed.");

            TotalComments++;
            Comments.Add(comment);
        }

Then I catch this ecxception at the controller level like so:

// process adding new comment
        try
        {
            accountTasks.PostProfileComment(user, account, profileComment);
        }
        catch (RulesException ex)
        {
            ex.AddModelStateErrors(ModelState);
        }

        if (!ModelState.IsValid)
        {
            return Json(ModelState.Errors());
        }

What would you reccomend as an alternative, or would you reccomend I stick with what I have?

  • 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-23T08:59:04+00:00Added an answer on May 23, 2026 at 8:59 am

    Like you, we wanted to be prepared for MVC3 and the removal of xVal. We removed the dependency by writing our own RulesException, ErrorInfo classes and extension method AddModelStateErrors added to our Framework.

    In this way, you only have to remove xVal, and resolve namespaces. If you have a refactoring tool, this is trivial.

    I have a gist with these classes.

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

Sidebar

Related Questions

i'm currently refactoring a C-project, throwing about 1000 warnings at me. is there a
Looking to do a bit of refactoring... Using NHibernate I have this query currently
I am currently refactoring a large Java application. I have split up one of
I am currently refactoring a project where so far a lot of data was
I am currently refactoring a project which has been halfheartedly ported to Yii. There
I have been refactoring the codebase of the project that I am currently on
I'm currently on a co-op term working on a project nearing completion with one
I have been tasked with refactoring a project that currently uses an EAV model
Currently, I am using CVS to keep track of my SourceForge project. I has
I am currently refactoring my code for a web application developed using ASP.NET MVC3

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.