Just add below code in contract class so that mandatory fields like date fields can be validated by throwing the warning.
public boolean validate()
{
boolean isValid = true;
if (!fromDate)
{
isValid = checkFailed("From Date should be entered");
}
if (!toDate)
{
isValid = checkFailed("To Date should be entered");
}
if (isValid && (fromDate > toDate))
{
isValid = checkFailed(strfmt("From Date should be less than or equal to To Date", date2StrUsr(fromDate, DateFlags::FormatAll), date2StrUsr(toDate, DateFlags::FormatAll)));
}
return isValid;
}
public boolean validate()
{
boolean isValid = true;
if (!fromDate)
{
isValid = checkFailed("From Date should be entered");
}
if (!toDate)
{
isValid = checkFailed("To Date should be entered");
}
if (isValid && (fromDate > toDate))
{
isValid = checkFailed(strfmt("From Date should be less than or equal to To Date", date2StrUsr(fromDate, DateFlags::FormatAll), date2StrUsr(toDate, DateFlags::FormatAll)));
}
return isValid;
}
No comments:
Post a Comment