I'm writing a custom validation attribute for validating zip\postal codes. For it to work I absolutely need to know the selected country. But it turns out to be surprisingly difficult to do.
In most view models nop passes the country using its id, which means I need to decipher it. The way to do it would be to use
CountryService since it can translate the id to country name, but the problem is how do I actually do that.
If I were to create a new
CountryService object I would have to also create and pass a number of dependencies (CacheService object etc.) and it sounds like the wrong way of achieving the result. So how do I actually use a Nop Service outside a controller (in my case inside a custom Validation Attribute)?