There are a lot of ways to validate data in FlexSheet. We will explain a simple way of validation, which is throwing an exception on passing an invalid value.
To validate data, we have created a class named ProductBase which contains data about product line, color, name, price, cost, weight, volume discontinued, and rating. Another class named ProductRow contains the SetValue method which simply throws exceptions when a property setter is passed an invalid value. This method allows for property-level validation only (no item-level validation). The following code implements data validation in SetValue method:
The ProductThrow class throws exception when a user sets price, cost or weight properties to a negative value or sets rating to a value less than zero and greater than 5.