public static MetadataPropertyHandle <TMetadata, Regex> EnsureValidRegex <TMetadata>( this MetadataPropertyHandle <TMetadata, string> hnd, RegexOptions regexOptions) where TMetadata : class, IMetadata { // hnd.EnsureHandleValid(); hnd.EnsureNotEmpty(); // try { var regex = hnd .PropertyValue .ArgProp(nameof(hnd.PropertyValue)) .ParseRegex(regexOptions: regexOptions) .Value; return (new MetadataPropertyHandle <TMetadata, Regex>( metadata: hnd.Metadata, propertyName: hnd.PropertyName, propertyValue: regex)); } catch (ArgumentException firstException) { throw hnd.P_CreateMetadataValidationException(firstException); } }
public static MetadataPropertyHandle <TMetadata, TimeSpan> EnsureGreaterThanZero <TMetadata>( this MetadataPropertyHandle <TMetadata, TimeSpan> hnd) where TMetadata : class, IMetadata { // hnd.EnsureHandleValid(); // try { hnd .PropertyValue .ArgProp(nameof(hnd.PropertyValue)) .EnsureGreaterThanZero(); } catch (ArgumentException firstException) { throw hnd.P_CreateMetadataValidationException(firstException); } // return(hnd); }
public static MetadataPropertyHandle <TMetadata, TPropertyValueItem[]> EnsureNoNullElements <TMetadata, TPropertyValueItem>( this MetadataPropertyHandle <TMetadata, TPropertyValueItem[]> hnd) where TMetadata : class, IMetadata { // hnd.EnsureHandleValid(); // try { hnd .PropertyValue .Arg(nameof(hnd.PropertyValue)) .EnsureNoNullElements(); } catch (ArgumentException firstException) { throw hnd.P_CreateMetadataValidationException(firstException); } // return(hnd); }
public static MetadataPropertyHandle <TMetadata, TMetadataRef> EnsureReachable <TMetadata, TMetadataRef>( this MetadataPropertyHandle <TMetadata, TMetadataRef> hnd) where TMetadata : class, IMetadata where TMetadataRef : class, IMetadataReference { // hnd.EnsureHandleValid(); // try { hnd .PropertyValue .EnsureReachable(@base: hnd.Metadata); } catch (ArgumentException firstException) { throw hnd.P_CreateMetadataValidationException(firstException); } // return(hnd); }
public static MetadataPropertyHandle <TMetadata, string> EnsureNotContains <TMetadata>( this MetadataPropertyHandle <TMetadata, string> hnd, char value) where TMetadata : class, IMetadata { // hnd.EnsureHandleValid(); // try { hnd .PropertyValue .ArgProp(nameof(hnd.PropertyValue)) .EnsureNotContains(value); } catch (ArgumentException firstException) { throw hnd.P_CreateMetadataValidationException(firstException); } // return(hnd); }
public static MetadataPropertyHandle <TMetadata, TPropertyValue> EnsureValid <TMetadata, TPropertyValue>( this MetadataPropertyHandle <TMetadata, TPropertyValue> hnd) where TMetadata : class, IMetadata where TPropertyValue : IValidatable { // hnd.EnsureHandleValid(); // if (hnd.PropertyValue != null) { try { hnd.PropertyValue.Validate(); } catch (Exception firstException) { throw hnd.P_CreateMetadataValidationException(firstException); } } // return(hnd); }
public static MetadataPropertyHandle <TMetadata, string> EnsureHasMaxLength <TMetadata>( this MetadataPropertyHandle <TMetadata, string> hnd, int maxLength) where TMetadata : class, IMetadata { // hnd.EnsureHandleValid(); // try { hnd .PropertyValue .Arg(nameof(hnd.PropertyValue)) .EnsureHasMaxLength(maxLength); } catch (ArgumentException firstException) { throw hnd.P_CreateMetadataValidationException(firstException); } // return(hnd); }
public static MetadataPropertyHandle <TMetadata, int> EnsureNotLessThan <TMetadata>( this MetadataPropertyHandle <TMetadata, int> hnd, int operand) where TMetadata : class, IMetadata { // hnd.EnsureHandleValid(); // try { hnd .PropertyValue .Arg(nameof(hnd.PropertyValue)) .EnsureNotLessThan(operand); } catch (ArgumentException firstException) { throw hnd.P_CreateMetadataValidationException(firstException); } // return(hnd); }
public static MetadataPropertyHandle <TMetadata, int?> EnsureBetween <TMetadata>( this MetadataPropertyHandle <TMetadata, int?> hnd, int bound1Inclusive, int bound2Inclusive) where TMetadata : class, IMetadata { // hnd.EnsureHandleValid(); // try { hnd .PropertyValue .Arg(nameof(hnd.PropertyValue)) .EnsureBetween(bound1Inclusive, bound2Inclusive); } catch (ArgumentException firstException) { throw hnd.P_CreateMetadataValidationException(firstException); } // return(hnd); }
public static MetadataPropertyHandle <TMetadata, string> EnsureNotEquals <TMetadata>( this MetadataPropertyHandle <TMetadata, string> hnd, ArgumentUtilitiesHandle <string> operand, StringComparison comparison) where TMetadata : class, IMetadata { // hnd.EnsureHandleValid(); // try { hnd .PropertyValue .ArgProp(nameof(hnd.PropertyValue)) .EnsureNotEquals(operand, comparison); } catch (ArgumentException firstException) { throw hnd.P_CreateMetadataValidationException(firstException); } // return(hnd); }