added rule isvalid method and tests