v0.1.0 #30
Replies: 2 comments 2 replies
-
I played around with this for bit: Feels good to use, and quite familiar if you have used the ruby version :) I know this is version 0.1 and all of that but below is some of my initial and random thoughts
One thing I really like with Ecto is that the abstraction is quite simple, custom validations is just another function you pipe your changeset through and it allows you to do more or less what you want with it. Makes it straighforwamd to compose logic. I somehow would like to use an even more declarative API where the schema could be expressed as data: %{
name: {:string, :filled?},
age: {:integer, gteq?: 0, optional: true},
description: {MyMarkDownType, :filled?},
tags: {{:list, {:string, :filled?}, :filled?}
}
Edit: Noticed there is already issues for a few my of bullet points :) |
Beta Was this translation helpful? Give feedback.
-
Thanks @kwando for taking the time to test it out and provide this great feedback! Here are my comments:
This is interesting. Funny how 🧠 works! For me me the way it works now reads very naturally: "cast a string into an integer" == This represents the flow too "try to cast to an integer" then "pass result to the type check predicate".
This is planned!
These types are already built-in when it comes to type-checks, casting is not fully supported though.
You can already inspect a schema via
This is supported already. You can reference a defined schema in a compiled module via
This is planned. Will be done prior 1.0.
Both Phoenix and Ecto integrations are planned. I'll be adding all this stuff to future roadmaps :)
I really like it too, actually. The idea behind rules is the same though, they are being applied one after the other but in a type-safe manner. I decided to go with the rule DSL because it can simplify your life a bit, but at the end of the day it's just piping data through functions.
Yes, this is already how it works. Schemas are data. The DSL produces this: %{
{:optional, :name} => {:type, {:string, []}},
{:required, :email} => {:type, {:string, []}}
} This is a raw schema map, but I'm planning to have a better representation eventually so that schema conversations can be easily implemented. Just like in |
Beta Was this translation helpful? Give feedback.
-
Drops.Contract
module for defining validation schemas with additional rulesDrops.Validator
module for running validation functions against inputDrops.Validator.Messages.DefaultBackend
that's configured by default in contractsDrops.Types
module with the following built-in types:Drops.Types.Type
- basic typeDrops.Types.List
- a list if member typeDrops.Types.Map
- a map with typed keysDrops.Types.Sum
- a composition of two typesDrops.Types.Cast
- a type that defines from-to casting types and caster optionsDrops.Predicates
module which provides many common predicate functions likefilled?
,gt?
,size?
etc.Drops.Casters
module which provides common type casting functions that can be used with the built-in typesThis discussion was created from the release v0.1.0.
Beta Was this translation helpful? Give feedback.
All reactions