I am a bit confused with a condition for writing a web services using php. I have a field type which should be w or d, nothing else. w is for weekdays like Monday, tuesday to Friday, and d is for dates like 2017-02-15
Basically what I want is if
type = w then days = Monday // It can be anything between Monday to Friday..
So how will i put validation for days field that i should be between Monday to Friday, It should give error if user enter anything else..?
Similarly if type = d then days = 2017-02-15 so if type is d and days should be a date like 2017-02-15 it should not be monday or any other characters or number, it should be a date.
This is what i have tried..
if (isset($this->inputs['day_type']) == 'w') {
// w = Monday, Tuesday etc
if (isset($this->inputs['days']) && !empty($this->inputs['days'])) {
$campaign->days= $campaign->days;
}
} elseif (isset($this->inputs['day_type']) == 'd') {
if (isset($this->inputs['dates']) && !empty($this->inputs['dates'])) {
$seperatingDates = explode(";", $this->inputs['dates']);
$campaign->days= $seperatingDates;
}
}
Aucun commentaire:
Enregistrer un commentaire