Skip Menu |

This queue is for tickets about the MooseX-Types-Email CPAN distribution.

Report information
The Basics
Id: 127631
Status: open
Priority: 0/
Queue: MooseX-Types-Email

People
Owner: Nobody in particular
Requestors: MANWAR [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: How do I test if email message is not valid?
Hi @Ether, Looking at the existing unit test. https://github.com/moose/MooseX-Types-Email/blob/master/t/01-email-abstract.t It takes a valid email message as string and validates it. However If I pass an invalid message i.e. message with no "To" and "From", it is still happy. Am I missing anything here? Thanks for the great work. Best Regards, Mohammad S Anwar
Can you include an example of something you think should fail The type check is just a wrapper around Email::Abstract, so if that module accepts your content, the type will as well.
Here is test: package MyClass; use Moose; use MooseX::Types::Email qw/EmailMessage/; has message => ( isa => EmailMessage, required => 1, is => 'ro' ); package main; my $ok_message =<<'VALID'; From: example@example.com To: example@example.com Subject: test Date: Tue Oct 20 21:57:31 2009 a body VALID my $not_ok_message =<<'INVALID'; Subject: test Date: Tue Oct 20 21:57:31 2009 a body INVALID my $ok = MyClass->new({ message => Email::Abstract->new($ok_message) }); my $not_ok = MyClass->new({ message => Email::Abstract->new($not_ok_message) }); print "OK.\n";
On 2018-11-12 08:17:21, MANWAR wrote: Show quoted text
> Hi @Ether, > > Looking at the existing unit test. > https://github.com/moose/MooseX-Types-Email/blob/master/t/01-email- > abstract.t > > It takes a valid email message as string and validates it. > > However If I pass an invalid message i.e. message with no "To" and > "From", it is still happy. > Am I missing anything here?
If Email::Abstract has any methods for validating the message, we can use that. But as it is now, if that class accepts the message, then we do too. I'll leave this open in case there is something we can do to validate.
Points well taken.