I have multiple methods which validates and return Boolean value a control. what can be best way to write the logic so that it validates and highlights all invalid controls, doesn't submit form to server and in future I have to make least code change if new control is added.
Aprroach 1. And , OR logic operator will not give correct result
if ( (Method1(ctrl1) && Method2(ctrl2) && Method3(ctrl3)))
{ // not submit to server }
else //submit the form
Approach 2 - still change in logic will require if new control is added for validation
var valid1 = Method1(ctrl1);
var valid2 = Method1(ctrl2);
var valid3 = Method1(ctrl3);
if(va1id1 && va1id2 && va1id3)
// not submit to server
else
// submit to server