A database I inherited stores multiple boolean values in a magic string. For example, the field PlantLocationString may have a value of "0, 1, 3" to indicate the record applies to manufacturing plants in Nebraska (0), Massachusetts (1) and Canada (3) but not to other locations California (2), Minnesota (4) etc. The poor design is repeated in multiple fields and I plan to leave the database unchanged.
To handle this oddity I created a ViewModel with boolean properties such as LocationNebraska = true, LocationCalifornia = false, etc. This ViewModel holds a reference to the source Model/Entity with the magic string field(s). In my controller I've added routines to convert the magic string to the appropriate boolean values and vice versa.
The problem is with ModelState and validation. PlantLocationString has a Required attribute yet only one or more boolean values needs to be selected (such as LocationNebraska). Check boxes in the View are bound to the ViewModel boolean fields. When the user checks "LocationNebraska" validation should succeed on HttpPost yet it fails - ModelState finds a null PlantLocationString field. Even after the controller populates PlantLocationString ModelState.IsValid remains false for that field.
How can I best handle this validation issue?