We can validate model itself by implementing IValidatableObject Interface. For validation you need to implement 'Validate' method of IValidatableObject Interface.
Here is some difference from the attribute validation version.
- In this for validation method is 'Validate' instead of 'IsValid' and also return type and parameter is different.
- The return type for Validate is an IEnumerable<ValidationResult>, because the logic inside this method is validating the entire model and might need to return more than a single validation error.
- No parameter is passed to Validate because you can directly access model properties because this Validate method is inside model.
Here is example for this.