Hi @Martin,
Returning null or empty list should work and it means no error.
Could you please paste your complete code so can have a look.
Cheers
Hi @Martin,
Returning null or empty list should work and it means no error.
Could you please paste your complete code so can have a look.
Cheers
Hi Martin,
If you're using yield to return errors, you can return a success by using "yield break;" (assuming you haven't already added an error using yield) like the following:
public IEnumerable<ValidationError> Validate(MyContentType instance) { if (string.IsNullOrEmpty(instance.MyProperty)) { yield return new ValidationError { ErrorMessage = "Fill in the property", Severity = ValidationErrorSeverity.Error }; } yield break; }
Instead of using yield return, what can work is to create a List<ValidationError> and add errors if any. In the end when you return it, it either contains errors or nothing.
Because the collection should be very small so it's not different with List<ValidationError> or a yield return.
Hi
I've implemeted the interface IValidate. In my Validate method, I can return error like following:
yield return new ValidationError
{
..
}
I'm unable to return success. Following is the statement, like seen in many articles. It's not working.
return Enumerable.Empty();
Question:
How to return no error for Validate method??