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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:18:21+00:00 2026-05-26T18:18:21+00:00

I have several applications within my domain that accept similar inputs in text fields.

  • 0

I have several applications within my domain that accept similar inputs in text fields. Each application implements its own validation. I want to bring that functionality into a class library so that rather than re-inventing the wheel on each project, our developers can quickly implement the validation library, and move on.

I’m not the best when it comes to OO design. What I need is the ability for a user to enter an arbitrary string, and then for the validation library to check it against the known types to make sure that it matches one of them. Should I build an interface and make each type of string a class that implements that interface? (seems wrong since I won’t know the type when I read in the string). I could use some help identifying a pattern for this.

Thanks.

  • 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-26T18:18:22+00:00Added an answer on May 26, 2026 at 6:18 pm

    I’ve always been a fan of Fluent Validation for .Net. If it’s more robust then you need, it’s functionality is easy enough to mimic on your own.

    If you’re interested, here’s a link to my very simple validation class. It’s similar in usage to Fluent Validation, but uses lambdas to create the validation assertions. Here’s a quick example of how to use it:

    public class Person
    {
        public Person(int age){ Age = age; }
        public int Age{ get; set;}
    }
    
    public class PersonValidator : AbstractValidator
    {
        public PersonValidator()
        {
            RuleFor(p => p.Age >= 0,
                () => new ArgumentOutOfRangeException(
                    "Age must be greater than or equal to zero."
            ));
        }
    }
    
    public class Example
    {
        void exampleUsage()
        {
            var john = new Person(28);
            var jane = new Person(-29);
    
            var personValidator = new PersonValidator();
    
            var johnsResult = personValidator.Validate(john);
            var janesResult = personValidator.Validate(jane);
    
            displayResult(johnsResult);
            displayResult(janesResult);
        }
    
        void displayResult(ValidationResult result)
        {
            if(!result.IsValid)
                Console.WriteLine("Is valid");
            else
                Console.WriteLine(result.Exception.GetType());
        }
    }
    

    (see source code for a more thorough example).

    Output:

    Is valid
    System.ArgumentOutOfRangeException
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that places several Windows within a com.extjs.gxt.desktop.client.Desktop. I need to
I have several applications that are part of a suite of tools that various
We have several .NET applications that monitor a directory for new files, using FileSystemWatcher.
I have several web applications in production that utilize NFS mounts to share resources
I have several different c# worker applications that run various continuous tasks: sending emails
I have several .NET Windows Forms applications that I'm preparing to convert into a
I have an application that spans several pages of engagement for the applicant and
Background: I work in a suite of ASP.NET applications that have several different modules.
I have a jar application that contains several reports (files .jasper ) and the
I want to use UITableViewCells within my application which have an image, and that

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.