GrantBirki / json-yaml-validate

A GitHub Action to quickly validate JSON and YAML files in a repository
MIT License
28 stars 11 forks source link

Unable to use "string" in enum as a value #38

Open MQ-xz opened 1 year ago

MQ-xz commented 1 year ago

Schema

args:
  - name:
      type: string
      required: true
    description:
      type: string
    required:
      type: boolean
    type:
      type: string
      enum: ["string", "url", "domain", "path", "status", "ip", "list"]

yml code

args:
  - description:
    name: domain
    required: false
    type: string

error got

| {
|     "file": "xxx/xxx.yml",
|     "errors": [
|       {
|         "path": "args.0.type",
|         "message": "args.0.type must be either function String() { [native code] }, url, domain, path, status, ip or list."
|       }
|     ]
|   },
GrantBirki commented 1 year ago

@MQ-xz Could it be due to the fact that your type is named type? What if you change your top level type value to something like kind:? Perhaps that would rule out the potential for a conflict on that keyword?

MQ-xz commented 1 year ago

I don't think so, since when removing the string from enum it's working fine. Also look at that error message. the string shows like a function ("String()") as an option in it.

Also I think the issue is only raised when we use a string as a type.