implemented a method of valid_type and valid_len