The JForm object has some great methods for dealing with exactly this situation. You can do validation on the front end using javascript, but you can also change the "required" and "validation" properties on the individual field objects of the JForm object. Here's a quick and dirty sample of code in the model. In this example,
$this refers to the JModel class or one of its child classes.
// GET THE DATA FROM THE POSTED FORM
$data = JRequest::getVar('jform', array(), 'post', 'array');
// USE THE MODEL CLASS TO LOAD THE FORM OBJECT.
$form = $this->getForm($data);
// GET THE VALUE OF A SPECIFIC FIELD
$a = $form->getValue('a');
// IF THE VALUE OF a IS ZERO, THEN b IS NOT REQUIRED
if((int)$a == 0){
$form->setFieldAttribute('b', 'required', 'false');
}
// VALIDATE THE FORM BASED ON CHANGES YOU MADE
$form->validate($data);
That's just a sample of the code that you could use, but the basic structure should hold true for any situation you can dream up. By default fields are either required or not, and they may or may not have filters set. By using the setFieldAttribute() method, you can change the default behavior of the form as defined in the forms XML file. You can totally rewrite the structure of the form on the fly by changing field attributes and adding or removing fields from the form object.