/// <summary> /// Constructor from other encapsulated value /// </summary> /// <exception cref="FormatException"></exception> public NotNullOrEmptyStringDecorator(IEncapsulatedValue <string> decorated) : base(decorated) { if (string.IsNullOrEmpty(decorated.Value)) { throw new FormatException(NullOrEmptyInputMessage); } }
/// <summary> /// Constructor from other encapsulated value /// </summary> /// <exception cref="FormatException"></exception> public MinimalLengthStringDecorator(int minLength, IEncapsulatedValue <string> decorated) : base(decorated) { if (decorated.Value.Length < minLength) { throw new FormatException(TooShortMessage(minLength)); } }
/// <summary> /// Constructor from other encapsulated value /// </summary> /// <exception cref="FormatException"></exception> public MaximalLengthStringDecorator(int limit, IEncapsulatedValue <string> decorated) : base(decorated) { if (decorated.Value.Length > limit) { throw new FormatException(LengthExceededMessage(limit)); } }
public RegexStringDecorator(IEncapsulatedValue <string> other, Regex regex) : base(other) { if (!regex.IsMatch(other.Value)) { throw new FormatException(BadInputMessage(other.Value, regex)); } }
/// <summary> /// Constructor from other instance /// </summary> protected EncapsulatedValueAbstract(IEncapsulatedValue <TValue> other) { Value = other.Value; }
public UpperInvariantStringDecorator(IEncapsulatedValue <string> other) : base(other.Value.ToUpperInvariant()) { }
/// <summary> /// Constructor from other encapsulated value /// </summary> /// <exception cref="FormatException"></exception> public AlphanumericStringDecorator(IEncapsulatedValue <string> decorated) : base(decorated, AlphanumericRegex) { }