Skip to content

Commit

Permalink
fix: add type validation for cell min/max
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahul-Siemens committed Jan 24, 2024
1 parent 4a461da commit f88793e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
10 changes: 10 additions & 0 deletions Src/DevAgeSourcePack4/ComponentModel/Validator/ValidatorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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);
}
}
Expand Down
25 changes: 21 additions & 4 deletions Src/DevAgeSourcePack4/Data/Exceptions/Exceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,27 @@ public ConversionErrorException(string destinationType, string value, Exception
}
}

/// <summary>
/// Common EventArgs class used to store and raise events with an Exception associated
/// </summary>
public class ExceptionEventArgs : EventArgs
/// <summary>
/// Validation exception
/// </summary>
[Serializable]
public class ValidationErrorException : DevAgeApplicationException
{
/// <summary>
/// Constructor
/// </summary>
/// <param name="type"></param>
/// <param name="value"></param>
public ValidationErrorException(string type, string value) :
base(value + " is not of type " + type + ".")
{
}
}

/// <summary>
/// Common EventArgs class used to store and raise events with an Exception associated
/// </summary>
public class ExceptionEventArgs : EventArgs
{
/// <summary>
/// Constructor
Expand Down

0 comments on commit f88793e

Please sign in to comment.