Thanks for any thoughts.
while I am working my way through some custom validationAttributes, I have come across a problem which should be simple, but has me stumped.
An authorized user will have a UserProfile which includes a key to the site they work in. This site is a record set within a database. 1 field in this site record set is a regular expression which denotes what would be a valid format for a field in a completely separate table. The data entered into this other table will be common to all registered users, but a particular field relates to the ID format used at their institution.
Is there a clean way I can dynamically add a regular expression validator to a property?
Thank you as always.
This is what I came up with, but keen to know if there are better solutions:
Naming conventions are to allow automapper to flatten the model (each StudyCentre has a many to 1 relationship with the RecordSystem (some systems share the patient indexing system)
As a nested class within the ViewModel for an indidual TrialParticipant
The other properties (such as StudyCentre.Abbreviation are for the labels)
The function RegEx is simply:
The Controller sets up the viewmodel like so:
and in the view (LabelDetailsfor is a custom helper):