Can I please get some help with the following? Is it acceptable practice to allow my functions to rely on require statements "passing" to return the correct value? In the example below if the function does not revert due to the require statements triggering, return true.
I understand that time calculation is not precise in Solidity and I'm using SafeMath. start
and end
are contract variables.
Example Function:
// ensure the current duration is valid.
function isValidDuration()
public
view
returns (bool)
{
uint32 calculatedDuration = uint32(end.sub(start));
require(
calculatedDuration >= 15 minutes,
"The minimum session duration is 15 minutes."
);
require(
calculatedDuration <= 1 weeks,
"The maximum session duration is 1 week."
);
return true;
}