Validate input and set duration.