public static PersonalNumberVO Create(string input) { var instance = new PersonalNumberVO { Value = input }; ValidateInstance(instance); return(instance); }
public static void ValidateInstance(PersonalNumberVO instance) { // Validations goes here if ( string.IsNullOrWhiteSpace(instance.Value) || instance.Value.Length != 11 || !Regex.Match(instance.Value, "^([0-9]+)$", RegexOptions.IgnoreCase).Success ) { throw new DomainException(DomainExceptionCode.InvalidPersonalNumber); } }