« blib/lib/JMAP/Validation/Generators/Contact.pm
↑ Summary
blib/lib/JMAP/Validation/Generators/File.pm »
| 1 | package JMAP::Validation::Generators::ContactInformation; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use JMAP::Validation::Generators::String; | ||
| 7 | use JSON::PP; | ||
| 8 | use JSON::Typist; | ||
| 9 | |||
| 10 | my %types = ( | ||
| 11 | emails => [qw{ | ||
| 12 | personal | ||
| 13 | work | ||
| 14 | other | ||
| 15 | }], | ||
| 16 | phones => [qw{ | ||
| 17 | home | ||
| 18 | work | ||
| 19 | mobile | ||
| 20 | fax | ||
| 21 | pager | ||
| 22 | other | ||
| 23 | }], | ||
| 24 | online => [qw{ | ||
| 25 | uri | ||
| 26 | username | ||
| 27 | other | ||
| 28 | }], | ||
| 29 | ); | ||
| 30 | |||
| 31 | sub generate { | ||
| 32 | my ($type) = @_; | ||
| 33 | |||
| 34 | my @ContactInformation; | ||
| 35 | |||
| 36 | foreach my $type_value (@{$types{$type} || []}) { | ||
| 37 | foreach my $label (JMAP::Validation::Generators::String->generate(), undef) { | ||
| 38 | foreach my $isDefault (JSON::PP::true, JSON::PP::false) { | ||
| 39 | push @ContactInformation, { | ||
| 40 | type => JSON::Typist::String->new($type_value), | ||
| 41 | label => $label, | ||
| 42 | value => JMAP::Validation::Generators::String->generate(), | ||
| 43 | isDefault => $isDefault, | ||
| 44 | } | ||
| 45 | } | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | return @ContactInformation; | ||
| 50 | } | ||
| 51 | |||
| 52 | 1; |