code: def test_as_raises_error_when_field_type_is_incorrect(self) -> None:
      with pytest.raises(
          AssetCardError,
          match=rf"^The value of the field 'field1' of the asset card 'test-card' must be of type `{int}`, but is of type `{str}` instead\.$",
      ):
          self.card.field("field1").as_(int)
  
      with pytest.raises(
          AssetCardError,
          match=rf"^The value of the field 'field2\.sub-field1' of the asset card 'test-card' must be of type `{int}`, but is of type `{str}` instead\.$",
      ):
          self.card.field("field2").field("sub-field1").as_(int)
  
imports: from os import PathLike
  from pathlib import Path
  import pytest
  from fairseq2.assets import AssetCard, AssetCardError, AssetCardFieldNotFoundError
label_desc: Use image node_id 5 for calling the TestAssetCard obj's underlying member method code with example usage: obj.test_as_raises_error_when_field_type_is_incorrect() without return types