Adzz / data_schema

Declarative schemas for data transformations.
Apache License 2.0
86 stars 9 forks source link

Should cast_fns be able to receive options... #26

Closed Adzz closed 2 years ago

Adzz commented 2 years ago

Example use case is something like:

field: {:sid, 
  {["Flight"], {:attr, "FlightKey"}}, 
  {StringType, trim: true, blank_as_nil: true}, 
  optional?: true
}

OR

field: {:sid, 
  {["Flight"], {:attr, "FlightKey"}}, 
  StringType, 
  optional?: true,
  cast_options: [trim: true, blank_as_nil: true]
}

This would be a breaking change so we'd need to think about how we could roll it out, especially given that most probably wont need the functionality.

Do we have two behaviours for cast_fns ?

Adzz commented 2 years ago

Closing as we can get what we want with the Mod Fun Args syntax right now:

field: {:sid, 
  {["Flight"], {:attr, "FlightKey"}}, 
  {StringType, :cast, [[trim: true, blank_as_nil: true]]}, 
  optional?: true
}