We handle birthdate
This commit is contained in:
1 parent
a5fe074b5d
commit
a19c433c4c
5 files changed
+48
-9
No files matched your search
@@ -10,7 +10,6 @@
|
||||
* "firstname": "Jon",
|
||||
* "lastname": "Hansen",
|
||||
* "email": "jon@uio.no",
|
||||
* "birthdate": "1985-03-01" // format: ISO-8601 date
|
||||
* "purchased": "2004-02-12" // optional, format: ISO-8601 date
|
||||
* }
|
||||
*
|
||||
@@ -64,7 +63,7 @@ if($data === NULL) {
|
||||
}
|
||||
|
||||
/* Validate supplied data */
|
||||
$required_keys = array('firstname', 'lastname', 'phone', 'email', 'birthdate');
|
||||
$required_keys = array('firstname', 'lastname', 'phone', 'email');
|
||||
$valid_keys = $required_keys;
|
||||
$valid_keys[] = + 'purchased';
|
||||
|
||||
@@ -129,12 +128,6 @@ if( strlen($data['lastname']) < 2) {
|
||||
echo json_encode(array('error' => 'Too short lastname: '.$data['lastname']));
|
||||
die();
|
||||
}
|
||||
/* validate birthdate */
|
||||
if( !valid_date($data['birthdate']) ) {
|
||||
set_response_code(400);
|
||||
echo json_encode(array('error' => 'Could not parse birthdate: \''.$data['birthdate'].'\''));
|
||||
die();
|
||||
}
|
||||
|
||||
/* Validate optional purchase_date */
|
||||
if( isset($data['purchased']) ) {
|
||||
|
||||
Reference in new issue
Block a user