2

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,425
  • 7
  • 32
  • 54

2 Answers2

6

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
  • 148
  • 3
  • 11
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
  • 26,101
  • 9
  • 68
  • 148