Closed DavidWood2001-zz closed 5 years ago
One way of doing this is to add data validation at the front end but this is messy and creates duplicate and redundant code in the back-end.
A more 'streamlined' approach would be to call the data validation from within the Property class onto the input as the validation is already created. This can be done by parsing the input values into the 'check' methods and then if none return a null then the object is created.
All of the important data validation (constraints of the data) are completed before creating an instance and only if none of the data is incorrect then it will create an instance of property.cs and add it into the search table as a valid item.
At the moment when an error is thrown the object is just created with whatever attribute had that error being set to the data types equivalent of null (e.g. int 0 or string ""). This is not acceptable as it means that objects can be created even if those objects are completely empty and meaningless in nature. For example if a user enters no name, hostID, hostName or latitude all will be defaulted to null making it harder for the search function in the future to return useful results. To avoid this the user needs to be directed to correct their input before the object is created.