hi Salsero,
let’s say you have defined a transition between workflowA/status1 to workflowB/status2, and you want to validate that when the AR performs this transition, its ‘category’ attribute is ‘required’.
Here is how you should define the validation rule :
...
array('status','SWValidator','enableSwValidation'=>true,'match'=>true),
array('category','required','on'=> 'sw:/workflowA\/1_workflowB\/2/'),
...
As you can see, the important stuff here is the value of the ‘on’ parameter. : “sw:/workflowA\/1_workflowB\/2/”
How does it work ?
Well, when the SWValidator is enabled, it is called when a transition is done and validates the ‘status’ attribute … but that’s not all ! It will also creates a scenario name and apply all validations rules defined for this scenario.
The scenario name created by SWValidator is built by concatenating, the start status, the underscore character , and the target status. In this case, the scenario will be : "[color="#0000FF"]workflowA/1_workflowB/2[/color]"
… so why not use this scenario name instead of this strange string with backslashes and stuff ?
Well, this is because you have decided to set the match parameter to true. In this case, SWValidator will consider the value of the ‘on’ parameter as a regular expression, and it will try to match the scenario name it creates for the transition, with this regular expression.
(Note that the "sw:" prefix is only here to prevent scenario collision)
So for the example above we would have :
- my record goes from workflowA/1 to workflowB/2
- the SWValidator is invoked and creates the scenario name "workflowA/1_workflowB/2"
- SWValidator will check each validation rule with a ‘on’ attribute and a scenario name starting with “sw:”
- for each one found, it will test if it matches "workflowA/1_workflowB/2" and if yes, it apply the validation rule
To create a regular expression that matches the string “workflowA/1_workflowB/2” you must escape the slash character … that’s why a backslash is needed (this is a nice page to tests regular expression
).
One last word : if you don’t need the match feature, you could have wrote your rules like this :
...
array('status','SWValidator','enableSwValidation'=>true,'match'=>false),
array('category','required','on'=> 'sw:workflowA/1_workflowB/2'),
...
Ok, after all this writting I hope didn’t lost you 
Do not hesitate to ask if things don’t work like they should (I mean … I’m only refering to the simpleWorkflow extension right ?
)
ciao
