=head3 My coercions stopped working with recent Moose, why did you break it?
-Moose 0.76 fixed a case where Coercions were being applied even if the original constraint passed. This has caused some edge cases to fail where people were doing something like
+Moose 0.76 fixed a case where coercions were being applied even if the original
+constraint passed. This has caused some edge cases to fail where people were
+doing something like
- subtype Address => as 'Str';
- coerce Address => from Str => via { get_address($_) };
+ subtype 'Address', as 'Str';
+ coerce 'Address', from 'Str', via { get_address($_) };
-Which is not what they intended. The Type Constraint C<Address> is too loose in this case, it is saying that all Strings are Addresses, which is obviously not the case. The solution is to provide a where clause that properly restricts the Type Constraint.
+This is not what they intended, because the type constraint C<Address> is too
+loose in this case. It is saying that all strings are Addresses, which is
+obviously not the case. The solution is to provide a C<where> clause that
+properly restricts the type constraint:
- subtype Address => as Str => where { looks_like_address($_) };
+ subtype 'Address', as 'Str', where { looks_like_address($_) };
-This will allow the coercion to apply only to strings that fail to look like an Address.
+This will allow the coercion to apply only to strings that fail to look like an
+Address.
=head2 Roles