vscode-yaml icon indicating copy to clipboard operation
vscode-yaml copied to clipboard

Incorrect type. Expected "ipv4"

Open mageo opened this issue 4 years ago • 1 comments

Describe the bug

Hello,

I have an issue with VSC not recognizing the IPv4 addresses in my YAML file when using a custom schema.

The custom schema is the following:

{
    "type": "object",
    "properties": {
        "net": {
            "type": "ipv4"
        },
        "mask": {
            "type": "ipv4"
        }
    },
    "required": [
        "net",
        "mask"
    ],
    "additionalProperties": false
}

When I apply this schema to the following YAML:

net: 192.168.1.0
mask: 255.255.255.0

It does not validate the IPv4 addresses and gives out the following error:

Incorrect type. Expected "ipv4".

Environment

  • [X] Windows (with project running in WSL)
  • [ ] Mac
  • [ ] Linux
  • [ ] other (please specify)

mageo avatar Dec 20 '21 08:12 mageo

Ok, I found my mistake.

If someone is facing the same issue someday, the correct usage of IPv4 in the schema is:

{
    "type": "object",
    "properties": {
        "net": {
            "type": "string",
            "format": "ipv4"
        },
        "mask": {
            "type": "string",
            "format": "ipv4"
        }
    },
    "required": [
        "net",
        "mask"
    ],
    "additionalProperties": false
}

Sorry for the noise.

mageo avatar Dec 20 '21 11:12 mageo