Optional Ardent Requirement

时间:2015-07-28 22:20:54

标签: php laravel ardent

I'm using Ardent with Laravel. We are working on a site that only allows US customers but we're extending it to Canadian customers as well. One of our requirements is that the zip code be 5-9 characters long, all numbers (we strip out the dash and other punctuation to validate).

We want to have validation for postal codes as well, but only for postal_codes to be required if zip_code is not offered (and vice versa). Is this possible? Theoretically we could use just one field but we'd have to have a more complex regex.

1 个答案:

答案 0 :(得分:2)

In my site, I handle this with a country field:

#pragma mark MonthView Delegate & DataSource
- (NSArray*) calendarMonthView:(TKCalendarMonthView*)monthView marksFromDate:(NSDate*)startDate toDate:(NSDate*)lastDate{
    [self generateRandomDataForStartDate:startDate endDate:lastDate];
    return self.dataArray;
}
- (void) calendarMonthView:(TKCalendarMonthView*)monthView didSelectDate:(NSDate*)date{
    NSLog(@"Date Selected: %@",date);
    [self.tableView reloadData];
}
- (void) calendarMonthView:(TKCalendarMonthView*)mv monthDidChange:(NSDate*)d animated:(BOOL)animated{
    [super calendarMonthView:mv monthDidChange:d animated:animated];
    [self.tableView reloadData];
}

You could also use required_without.