public void Validate() { Contract.Requires(this.ProductVersion != null); string errorMessage; if (!NexusUtilities.CheckNamingConvention(this.Id, out errorMessage)) { throw new Exception($"The ID is invalid: { errorMessage }"); } }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { var name = value as string; if (NexusUtilities.CheckNamingConvention(name, out var errorDescription)) { return(ValidationResult.Success); } else { return(new ValidationResult(errorDescription)); } }
public DataWriterContext(string systemName, string dataDirectoryPath, NexusProjectDescription projectDescription, IList <CustomMetadataEntry> customMetadataEntrySet) { Contract.Requires(customMetadataEntrySet != null); customMetadataEntrySet.ToList().ForEach(customMetaDataEntry => { if (!NexusUtilities.CheckNamingConvention(customMetaDataEntry.Key, out errorDescription)) { throw new ArgumentException($"Argument '{ nameof(customMetadataEntrySet) }', value '{ customMetaDataEntry.Key }': { errorDescription }"); } }); this.SystemName = systemName; this.DataDirectoryPath = dataDirectoryPath; this.ProjectDescription = projectDescription; this.CustomMetadataEntrySet = customMetadataEntrySet; }
public void Validate() { string errorMessage; if (this.Version < 0) { throw new Exception(ErrorMessage.NexusProjectDescription_InvalidVersion); } if (!NexusUtilities.CheckNamingConvention(this.PrimaryGroupName, out errorMessage)) { throw new Exception($"The PrimaryGroupName is invalid: { errorMessage }"); } if (!NexusUtilities.CheckNamingConvention(this.SecondaryGroupName, out errorMessage)) { throw new Exception($"The SecondaryGroupName is invalid: { errorMessage }"); } if (!NexusUtilities.CheckNamingConvention(this.ProjectName, out errorMessage)) { throw new Exception($"The ProjectName is invalid: { errorMessage }"); } }