diff --git a/Src/DevAgeSourcePack4/ComponentModel/Validator/ValidatorBase.cs b/Src/DevAgeSourcePack4/ComponentModel/Validator/ValidatorBase.cs index da07b40..93db36c 100644 --- a/Src/DevAgeSourcePack4/ComponentModel/Validator/ValidatorBase.cs +++ b/Src/DevAgeSourcePack4/ComponentModel/Validator/ValidatorBase.cs @@ -498,6 +498,11 @@ public object MinimumValue if (m_MinimumValue != value) { m_MinimumValue = value; + + if (m_MinimumValue.GetType() != ValueType) + { + throw new ValidationErrorException(ValueTypeName, ObjectToStringForError(m_MinimumValue)); + } OnChanged(EventArgs.Empty); } } @@ -515,6 +520,11 @@ public object MaximumValue if (m_MaximumValue != value) { m_MaximumValue = value; + + if (m_MaximumValue.GetType() != ValueType) + { + throw new ValidationErrorException(ValueTypeName, ObjectToStringForError(m_MaximumValue)); + } OnChanged(EventArgs.Empty); } } diff --git a/Src/DevAgeSourcePack4/Data/Exceptions/Exceptions.cs b/Src/DevAgeSourcePack4/Data/Exceptions/Exceptions.cs index 2d9488e..dfa819a 100644 --- a/Src/DevAgeSourcePack4/Data/Exceptions/Exceptions.cs +++ b/Src/DevAgeSourcePack4/Data/Exceptions/Exceptions.cs @@ -127,10 +127,27 @@ public ConversionErrorException(string destinationType, string value, Exception } } - /// - /// Common EventArgs class used to store and raise events with an Exception associated - /// - public class ExceptionEventArgs : EventArgs + /// + /// Validation exception + /// + [Serializable] + public class ValidationErrorException : DevAgeApplicationException + { + /// + /// Constructor + /// + /// + /// + public ValidationErrorException(string type, string value) : + base(value + " is not of type " + type + ".") + { + } + } + + /// + /// Common EventArgs class used to store and raise events with an Exception associated + /// + public class ExceptionEventArgs : EventArgs { /// /// Constructor