public DomainSpec Parse(string domainSpecString, bool mandatory) { DomainSpec domainSpec = new DomainSpec(domainSpecString); if (string.IsNullOrEmpty(domainSpecString)) { if (mandatory) { string message = string.Format(SpfParserResource.NoValueErrorMessage, "domain"); string markdown = string.Format(SpfParserMarkdownResource.NoValueErrorMessage, "domain"); Guid id = Guid.Parse("5E60D21F-A543-4263-9525-FE6E2E330E52"); domainSpec.AddError(new Error(id, ErrorType.Error, message, markdown)); } } else if (!_domainRegex.IsMatch(domainSpecString) && !_macroRegex.IsMatch(domainSpecString)) { string message = string.Format(SpfParserResource.InvalidValueErrorMessage, "domain or macro", domainSpecString); string markdown = string.Format(SpfParserMarkdownResource.InvalidValueErrorMessage, "domain or macro", domainSpecString); Guid id = Guid.Parse("38A767C4-B795-4B57-8779-5D535B4347BB"); domainSpec.AddError(new Error(id, ErrorType.Error, message, markdown)); } return(domainSpec); }
public DomainSpec Parse(string domainSpecString, bool mandatory) { DomainSpec domainSpec = new DomainSpec(domainSpecString); if (string.IsNullOrEmpty(domainSpecString)) { if (mandatory) { string errorMessgae = string.Format(SpfParserResource.NoValueErrorMessage, "domain"); domainSpec.AddError(new Error(ErrorType.Error, errorMessgae)); } } else if (!_domainRegex.IsMatch(domainSpecString) && !_macroRegex.IsMatch(domainSpecString)) { string errorMessage = string.Format(SpfParserResource.InvalidValueErrorMessage, "domain or macro", domainSpecString); domainSpec.AddError(new Error(ErrorType.Error, errorMessage)); } return(domainSpec); }