Then, before instantiating a validable object, I will execute the validation to prevent illegal values. Or just throw an exception if the validation fails?It seems to me the best option would be boolean returning methods and throw the exception when the object is instantianted, for example: It is OK to delegate any logic by means of composition if that logic is going to change dynamically during the execution of a program.
Imagine writing your validate method for a project that has over 100 models with 5 required fields in each of them.
But I feel if we can validate inputs on the client itself it would help us save a lot of things like: Now that the problem is evident, we must do something to cater to users' needs.
If you’ve ever thought about this problem, you are a good programmer who not just wants to write and deliver code but also wants to use resources the codes runs on “very judiciously.” The first solution that I could think about was to write a method in each model to check if the fields that you want should be required should not be null. Else you must check for the problem and do the needful to pass the validation.
If programs are not carefully written, attackers can construct inputs that can cause malicious code to be executed.
If video does not work, try refreshing the page: All input data is a potential source of problems.