'Optional Model Validation in Razor Page
I have a "create account" form where I would like to collect data related to more than one model. While this is easy to accomplish, I am not able to figure out how to make the validation optional in the case where I would like to make something optional. Consider the example below.
Pseudo Code Form
Create Account
Account Name
…
Create Primary Contact
Contact Name
Contact Email
Create Contact Address (Optional)
[ ] Skip Address
Address Type
Street
City, State zip
In this example, I would like the validation to run on "create account", "create primary contact," and on the "create contact address" if the "Skip Address" is not selected. Please note that each of the sections above has its own model and own database repository.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
