Type validation and conversion