Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to write enum types as a short hand ? + enum validation bug #311

Open
m0x61h0x64i opened this issue Sep 30, 2022 · 1 comment
Open

Comments

@m0x61h0x64i
Copy link

m0x61h0x64i commented Sep 30, 2022

hi, i want to write enum type and its values in shorthand syntax, but how?

'enum|values:1, 2'

it throws an error in the console :

/node_modules/fastest-validator/lib/rules/enum.js:10
                                ${this.makeError({ type: "enumValue", expected: "\"" + schema.values.join(", ") + "\"", actual: "value", messages })}
TypeError: schema.values.join is not a function

also this doesnt work :

'enum|values:[1, 2]'

i got a bug with using normal syntax, the message of the validation is wrong, it says field value is 'pop, rap' but it should be the actual 'as' value...

[
  {
    type: 'enumValue',
    message: "The 'category' field value 'pop, rap' does not match any of the allowed values.",
    field: 'category',
    expected: 'pop, rap',
    actual: 'as'
  }
]
@m0x61h0x64i m0x61h0x64i changed the title how to write enum types as a short hand ? how to write enum types as a short hand ? + enum validation bug Sep 30, 2022
@icebob
Copy link
Owner

icebob commented Oct 1, 2022

Enum values have no shorthand format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants