/// <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);
     }
 }
Example #2
0
 /// <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));
     }
 }
Example #4
0
 public RegexStringDecorator(IEncapsulatedValue <string> other, Regex regex) : base(other)
 {
     if (!regex.IsMatch(other.Value))
     {
         throw new FormatException(BadInputMessage(other.Value, regex));
     }
 }
Example #5
0
 /// <summary>
 /// Constructor from other instance
 /// </summary>
 protected EncapsulatedValueAbstract(IEncapsulatedValue <TValue> other)
 {
     Value = other.Value;
 }
Example #6
0
 public UpperInvariantStringDecorator(IEncapsulatedValue <string> other) : base(other.Value.ToUpperInvariant())
 {
 }
Example #7
0
 /// <summary>
 /// Constructor from other encapsulated value
 /// </summary>
 /// <exception cref="FormatException"></exception>
 public AlphanumericStringDecorator(IEncapsulatedValue <string> decorated) : base(decorated, AlphanumericRegex)
 {
 }