params icon indicating copy to clipboard operation
params copied to clipboard

Feature Request: Put functions in the schema values

Open SkipMike opened this issue 8 years ago • 1 comments

I love this library, but I almost never build my own changeset validation functions because it's too cumbersome. I usually just use with after using params validation for types.

However, I think that it would be awesome if we could put validation functions in the schema. Could we somehow detect those and build a changeset validation out of functions, as long as they have the right call signature?

defparams asdf %{
  x!: fn :x, x -> is_integer(x) and x > 0 end,
  y!: :string,
}

This would satisfy the other 20% of api validation that I need. I'm happy to take a stab at this, if you guys think that it's feasible and desirable.

SkipMike avatar Dec 22 '17 05:12 SkipMike

I'd be happy with functions as values in default:

Use case: auto-generate ids.

towhans avatar Jan 24 '22 11:01 towhans