We have a flex application with many screens, and need to programmatically run all validators in all screens, before doing a specific server action. Hence, we need to have all validators registered somewhere central, to be able to iterate them and execute validate on each. Only if all answer OK, will we execute the rest of the command. The problem is:
* a flex validator is a view-thing: It is defined in mxml, and heavily bound to a specific input field
* the action, which needs to check all validators before executing logic, shall be in a command, as it is business logic
So, where do we place the validators? We can see at least two solutions:
1) Let mediators "register" their validator instances, by putting them into the model in a list, somewhere
This way the command can easily access them all. Bad thing is, that it seems wrong, to keep references to validators in ones model. Maybe this can be made a bit better, by hiding them through some model interface.
or,
2) Let command retrieve all mediators by name, and execute a validation on each, possibly through an interface, if the particular mediator implements that validator interface.
But is it good to have a command retrieve mediators?
Which one is best? Are there other, better solutions to this problem?