Dofactory.com
Dofactory.com
 Back to list
Views:   6.5K
Replies:  1
Archived

ValidateIPAddress.cs - constructor correct?

Hi, 

Can someone please confirm whether the second constructor in the following codefile (ValidateIPAddress.cs, from Patterns in action 4.0) is correct?
//ValidateIPAddress.cs:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusinessObjects.BusinessRules
{
    /// <summary>    
    /// IP Address validation rule.    
    /// </summary>    
    public class ValidateIPAddress : ValidateRegex
    {
        // Match IP Address
        public ValidateIPAddress(string propertyName) :
            base(propertyName, @"^([0-2]?[0-5]?[0-5]\.){3}[0-2]?[0-5]?[0-5]$")
        {
            ErrorMessage = propertyName + " is not a valid IP Address";
        }

        public ValidateIPAddress(string propertyName, string errorMessage) :
            this(propertyName)
        {
            ErrorMessage = errorMessage;
        }
    }
}

 
Ole Johnny Gjen, Jun 08, 2011
Reply 1
Hello Ole Johnny:

The second (overloaded) constructor seems fine to me.
Is there any particular reason why you think it is not correct or obsolete?
Dan McMillan, Jun 08, 2011
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.