1

How to achieve RequiredIf conditional operation in .NET Core for Model based validation.

In ASP.NET MVC, had used with ExpressiveAnnotation package but its not working for .NET Core.

user3711357
  • 1,259
  • 7
  • 27
  • 52

2 Answers2

5

UoN.ExpressiveAnnotations.NetCore is the package used for .NET Core applications same functionality as ExpressiveAnnotation package for MVC

Reference URL: https://github.com/uon-nuget/UoN.ExpressiveAnnotations.NetCore

Melody Magdy
  • 119
  • 4
  • 10
0

You can extend RequiredAttribute to check the property value and according to that manually check IsNullOrWhiteSpace of current property .

You can find the code sample here . Here is another code sample using custom ValidationAttribute .

Nan Yu
  • 23,741
  • 6
  • 55
  • 129