Changes for version 0.025 - 2018-06-02
- INCOMPATIBLE CHANGE
- Bump coerce module's metadata version from 2 to 3. This is to allow the coercer code to return error message (when coercion fails) in addition to coerced data. The metadata property 'might_die' is now replaced by 'might_fail'. The coercer code is not expected to die, unless there's an extraordinary situation in which case the whole coercer code or schema validator code which uses the coercer code will die anyway. Instead, when 'might_fail' is set to true, the coercer code is expected to return an array containing (error_message, coerced_data) instead of just coerced_data. When coercion succeeds, error_message should be set to undef and when coercion fails, error_message is set to a string detailing why coercion fails, and coerced_data is set to undef.
Modules
Coercion rules for Data::Sah
Coerce 0 to false and 1 to true
Coerce "true","yes",etc to true and "false","no",etc to false
Coerce date from number (assumed to be epoch)
Coerce date from Date object
Coerce date from string
Coerce duration from number (assumed to be number of seconds)
Coerce duration from (subset of) ISO8601 string (e.g. "P1Y2M", "P14M")
Convert "yes","true",etc to "1", and "no","false",etc to ""
Coerce date from number (assumed to be epoch)
Coerce date from DateTime object
Coerce date from Time::Moment object
Coerce date from (a subset of) ISO8601 string
Coerce duration from float (assumed to be number of seconds)
Coerce date from DateTime object
Coerce duration from human notation string (e.g. "2 days 10 hours", "3h")
Coerce duration from (subset of) ISO8601 string (e.g. "P1Y2M", "P14M")
Coerce float from percent string (e.g. "100.5%")
Coerce int from percent string (e.g. "100%")
Common stuffs for Data::Sah::Coerce and Data::Sah::CoerceJS
Generate coercer code