algae icon indicating copy to clipboard operation
algae copied to clipboard

Validators

Open expede opened this issue 9 years ago • 3 comments

Add the ability to validate entire ADTs, similar to Ecto models. Validation of individual fields should be left to #2. This feature is meant to enforce structure among fields.

defdata AcuteTriangle, validate: acute do
  angle1: float
  angle2: float
end

defp acute(%AcuteTriangle{angle1: angle1, angle2: angle2}) do: abs(angle1 - angle2) < 90.0

expede avatar Jan 04 '16 01:01 expede

where does the macro defadt exist. I tried import Algae and Use Witchcraft as well. No luck

hariroshan avatar Nov 22 '18 08:11 hariroshan

Hey @hariroshan 👋

This Issue is from the earliest days of the project, and defadt has since been renamed to defdata, and the syntax changed quite a lot as well. I'll update the text to reflect this. Thanks for pointing it out :)

expede avatar Nov 22 '18 15:11 expede

Commented about this in #2. See comment.

toraritte avatar Mar 05 '19 19:03 toraritte