Skip to content

Commit

Permalink
fix: add type validation for cell min/max (#27)
Browse files Browse the repository at this point in the history
- add type validation for cell min/max
  • Loading branch information
Rahul-Siemens committed Jan 25, 2024
1 parent 4a461da commit cab52e7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# SourceGrid

## [3.0.0] - 2024-01-18
## [3.0.0] - 2024-01-29

### Major Changes

- Migrate to .net 8.0 related to #3
- Deprecated DevAge Serialization

### Fixed

- Fixed bug in validator base related to #25

## [2.0.0] - 2023-11-24

### Major Changes
Expand Down
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 cab52e7

Please sign in to comment.