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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:38:56+00:00 2026-06-12T12:38:56+00:00

I have defined classes like Email,Url,Alphabet,Number and … just to centralize the validation logic

  • 0

I have defined classes like Email,Url,Alphabet,Number and … just to centralize the validation logic needed for each of these objects , like :

public class Email
{
    private string value;
    private bool isValid;

    const string RegexPattern = @"^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$";


        public Email(string address, int minLength = 8, int maxLength = 50)
        {
            value = address;

            isValid = Validator.IsValid(address,RegexPattern,minLength,maxLength);
        }

        public string Address
        {
            get
            {
                return value;
            }
        }

        public bool IsValid
        {
            get
            {
                return isValid;
            }
        }


}

can this be called a value object ?if not what it lacks ?

  • 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-12T12:38:58+00:00Added an answer on June 12, 2026 at 12:38 pm

    The implementation is one I would expect for a value object. It is immutable (though you may want to add readonly modifiers on the fields) and doesn’t seem to have its own identity.

    You need to consider whether it is indeed a value object depending on the domain – that’s how you decide whether this should be a value object or not.

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

Sidebar

Related Questions

I'm trying to create classes to encapsulate validation and logic for objects like Email
I have the following classes defined to do validation: public class DefValidator : IValidate<IDef>
I have two classes defined like public class PostleitzahlList : ObservableCollection<Postleitzahl> { } public
I am working in cross platform C++, and have some classes defined like so:
I have two connected classes defined like this: [ActiveRecord] public class Store : ActiveRecordBase<Store>
I have a method and two classes defined like this: template<template<class X> class T>
got a question regarding serializing classes that I've defined. I have some classes like
Sometimes we have defined some elements with multiple classes like :- <div class=a b
I have defined an Event class: Event and all the following classes inherit from
if I have two classes, and have defined an explicit type conversion between them,

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.