Skip to content

Commit d0291f6

Browse files
committed
Apply coercion to allow round-trip of boolean through JSON
The field is_pause_custodial_account is declared as a Bool, but this type restricst values to empty string, zero or one. When served as a JSON document, this gets converted to a JSON boolean 'true' or 'false'. When parsed back to Perl, this becomes a JSON::Boolean object. JSON::Boolean objects do not match the type constraint of Bool, and cannot be used to construct ..Document::Author. In particular, this is breaking the ability to update the profiles of metacpan in metacpan/metacpan-web/issues/2694 Adding `coerce => 1` allows the JSON::Boolean to get transformed to '' or 1, permitting a round trip without changing any representation of the boolean.
1 parent 10a6d7d commit d0291f6

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/MetaCPAN/Document/Author.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ has updated => (
106106
has is_pause_custodial_account => (
107107
is => 'ro',
108108
isa => Bool,
109+
coerce => 1,
109110
default => 0,
110111
);
111112

0 commit comments

Comments
 (0)