Description
In class FormComponent, in method validate(), isValid() is called too many times.
The last call can be removed by refactoring as follows:
Original 1.4 code:
public void validate()
{
validateRequired();
if (isValid())
{
convertInput();
if (isValid() && isRequired() && getConvertedInput() == null && isInputNullable())
{ reportRequiredError(); }if (isValid())
{ validateValidators(); } }
}
Refactored:
public void validate()
{
validateRequired();
if (isValid())
{
convertInput();
if(isValid())
{
// Check again because we think that convertInput() can set
// input to null after validateRequired() found valid input.
// When can convertInput() set input to null again?
if (isRequired() && getConvertedInput() == null && isInputNullable())
else
{ validateValidators(); } }
}
}