use of org.wikivoyage.listings.validators.EmailValidator in project wikivoyage-listings by baturin.
the class Main method validate.
private static Iterable<Listing> validate(Iterable<Listing> listingIterable) {
Iterable<Listing> validatedIterable = listingIterable;
Validator[] validators = { new LatitudeValidator(), new LongitudeValidator(), new WebsiteURLValidator(), new EmailValidator(), new WikidataValidator() };
for (Validator validator : validators) {
validatedIterable = validator.validate(validatedIterable);
}
return validatedIterable;
}
use of org.wikivoyage.listings.validators.EmailValidator in project wikivoyage-listings by baturin.
the class TestWikivoyagePOI method email.
@Test
public void email() {
// Valid
Listing p1 = TestWikivoyagePOI.createWithEmail("mary@wikivoyage.org");
// Invalid
Listing p2 = TestWikivoyagePOI.createWithEmail("\"mary@wikivoyage.org");
Listing p3 = TestWikivoyagePOI.createWithEmail("mary@wikivoyage.org, jane@wikivoyage.org");
Listing p4 = TestWikivoyagePOI.createWithEmail("mary@wikivoyage.org (reservations)");
Listing p5 = TestWikivoyagePOI.createWithEmail("http://wikivoyage.org");
// Prepare validation iterator
Iterator<Listing> validationIterator = new EmailValidator().validate(Arrays.asList(p1, p2, p3, p4, p5)).iterator();
// Check results
assertTrue(validationIterator.next().isValid());
assertFalse(validationIterator.next().isValid());
assertFalse(validationIterator.next().isValid());
assertFalse(validationIterator.next().isValid());
assertFalse(validationIterator.next().isValid());
}
Aggregations