drops icon indicating copy to clipboard operation
drops copied to clipboard

Enum support

Open torepettersen opened this issue 8 months ago • 2 comments

Thanks again for this lovely library :blush:

Would you consider adding Enum's to this library? Seems like it is a common enough use case that it is suppored for JSON Schemas.

Not sure what the best way to add enum support would be, but I would be happy to contribute.

One option could be an enum type:

schema do
  %{
    required(:some_enum) => type(:enum, values: ["some_string", 1, :some_atom])
  }

The other option seems like adding a validation in Drops.Predicates.

  %{
    required(:some_enum) => type(:any, values: ["some_string", 1, :some_atom])
  }

Seems like we would need a validation either way. So might make sense to start there? Any maybe add a enum type where the values would be a required validation?

torepettersen avatar Jun 08 '24 11:06 torepettersen