Validate data is included in Ecto Changeset
validate_inclusion/4
allows you to validate that specific data is included in a changeset. One way you could use it is by restricting a field's accepted values like this:
changeset
|> validate_inclusion(:direction, ["left", "right"])
if the value of the :direction field is not "left" or "right" a validation error will be added to the changeset
Tweet