« lib/JMAP/Validation/Tests/ContactInformation.pm
↑ Summary
blib/lib/JMAP/Validation/Generators/ContactGroup.pm »
| 1 | package JMAP::Validation::Generators::SetError; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use JMAP::Validation::Generators::String; | ||
| 7 | use JSON::Typist; | ||
| 8 | |||
| 9 | my %types = ( | ||
| 10 | invalidArguments => { | ||
| 11 | description => JMAP::Validation::Generators::String->generate(), | ||
| 12 | }, | ||
| 13 | invalidProperties => { | ||
| 14 | properties => [], | ||
| 15 | description => JMAP::Validation::Generators::String->generate(), | ||
| 16 | }, | ||
| 17 | ( | ||
| 18 | map { $_ => undef } | ||
| 19 | qw{ | ||
| 20 | accountReadOnly | ||
| 21 | fromAccountNoMail | ||
| 22 | fromAccountNotFound | ||
| 23 | invalidMailboxes | ||
| 24 | maxQuotaReached | ||
| 25 | notFound | ||
| 26 | stateMismatch | ||
| 27 | toAccountNoMail | ||
| 28 | toAccountNotFound | ||
| 29 | } | ||
| 30 | ), | ||
| 31 | ); | ||
| 32 | |||
| 33 | sub generate { | ||
| 34 | my (@types) = @_; | ||
| 35 | |||
| 36 | my @SetErrors; | ||
| 37 | |||
| 38 | foreach my $type (@types ? @types : (keys %types)) { | ||
| 39 | push @SetErrors, { | ||
| 40 | type => JSON::Typist::String->new($type), | ||
| 41 | ($types{$type} ? (%{$types{$type}}) : ()), | ||
| 42 | }; | ||
| 43 | } | ||
| 44 | |||
| 45 | return \@SetErrors; | ||
| 46 | } | ||
| 47 | |||
| 48 | 1; |