Skip to content

Commit

Permalink
fix(datamapper): returns the value if it is considered empty
Browse files Browse the repository at this point in the history
Using checker.isEmpty null, undefined, {} or "" values will be returned by themselves, without being
converted to null or undefined and without being passed to the parser.

BREAKING CHANGE: This can change the way a value that does not exist in the collection is
undefined in the application that uses the lib.
A null value is returned as null, but an
undefined is passed to the parser and can return a different value.
Instead of "undefined",
undefined will be returned, causing breaking changes in systems that expect "undefined" with a
string type.

herbsjs#36 and herbsjs#39
  • Loading branch information
vitorgamer58 committed Oct 21, 2023
1 parent ab2d23b commit 3a7f5f6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/dataMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class DataMapper {
}

function dataParser(value, parser) {
if (value === null) return null
if (checker.isEmpty(value)) return value
return parser(value)
}

Expand Down

0 comments on commit 3a7f5f6

Please sign in to comment.