On 28.1.2011 22:35, Hans Dieter Pearcey wrote:
On Fri, 28 Jan 2011 22:17:24 +0100, Jiří Pavlovský<j...@getnet.cz> wrote:
subtype MaybeSubject => as 'Maybe[Subject]';
coerce 'MaybeSubject'
=> from 'Subject'
It actually is.
=> from 'Str'
The first posted version was result of my random attempts to get it working.
Sorry for the confusion
=> via {
my $sanitized =sanitize_input($_);
$sanitized;
};
This doesn't make any sense to me.
Otherwise I get an error that attribute cannot have coearcion unless its
type has coearcion.
If your answer to "why are you doing this" is "otherwise I get an error", you
don't understand what you're doing and you're probably doing it wrong.
Finally, Maybe[Anything] is often a design smell, and using Maybe in coercions
even more so. Why do you need the possibility of undef?
Well, the attribute can be unset, so what else can I do? Defaulting to
empty string?