Skip to content

How to validate a union type of an enum and a collection of this enum in query parameters? #1734

Answered by Romakita
gloomybrain asked this question in Q&A
Discussion options

You must be logged in to vote

Because @AnyOf(Color, array().items(Color)) is probably not correct.

Try that:

  @CollectionOf(Color)
  @OnDeserialize(deserializeColors)
  public color: Color[]

I think it should works, because, the ValidationService will try to coerce data before validating it and the deserializeColors will map correctly the data to an array

See you
romain

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@gloomybrain
Comment options

@Romakita
Comment options

@gloomybrain
Comment options

@Romakita
Comment options

@gloomybrain
Comment options

Answer selected by gloomybrain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants