Skip to content

Enum support #51

@torepettersen

Description

@torepettersen

Thanks again for this lovely library 😊

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions