[Updated] API Checker.php to allow UTF-8 'letters' -> 'lettersutf8' for users' firstname/lastname

This commit is contained in:
xdrm-brackets 2017-02-17 11:59:57 +01:00
parent 15c2dacd22
commit 7b4cdbc20f
3 changed files with 14 additions and 6 deletions

View File

@ -99,6 +99,10 @@
return $checker && is_string($value) && preg_match('/^[\w\.-]+$/ui', $value);
break;
case 'lettersutf8':
return $checker && is_string($value) && preg_match('/^[^\W\d]+$/ui', $value);
break;
case 'letters':
return $checker && is_string($value) && preg_match('/^[a-z -]+$/i', $value);
break;
@ -107,6 +111,10 @@
return $checker && is_numeric($value) && floor($value) == $value && $value >= 0 && $value <= 100;
break;
case 'rfid':
return $checker && preg_match('@^[\dA-F]{2}(?:\-[\dA-F]{2}){3,5}$@', $value);
break;
// Tableau non vide
case 'array':
return $checker && is_array($value) && count($value) > 0;

View File

@ -1082,9 +1082,9 @@
$formatted[$i][$index] = floatval( $value );
// String utf8 management
elseif( \mb_detect_encoding($value) === 'UTF-8' )
$formatted[$i][$index] = utf8_encode($value);
$formatted[$i][$index] = $value;
else
$formatted[$i][$index] = utf8_encode(utf8_decode($value));
$formatted[$i][$index] = utf8_encode($value);
// Si pas non plus une aggrégation et si indice numérique, on le retire
}else if( !preg_match('/^agg_.+/', $index) && is_numeric($index) )

View File

@ -92,8 +92,8 @@
"parameters": {
"code": { "description": "Code RFID de l'utilisateur.", "type": "rfid" },
"username": { "description": "Identifiant de l'utilisateur.", "type": "varchar(1,30,alphanumeric)" },
"firstname": { "description": "Prénom de l'utilisateur.", "type": "varchar(3,30,letters)" },
"lastname": { "description": "Nom de l'utilisateur.", "type": "varchar(3,30,letters)" },
"firstname": { "description": "Prénom de l'utilisateur.", "type": "varchar(3,30,lettersutf8)" },
"lastname": { "description": "Nom de l'utilisateur.", "type": "varchar(3,30,lettersutf8)" },
"mail": { "description": "Adresse mail de l'utilisateur.", "type": "mail" }
},
"output": {
@ -193,8 +193,8 @@
"id_user": { "description": "UID de l'utilisateur.", "type": "id" },
"code": { "description": "Code RFID de l'utilisateur.", "type": "rfid", "optional": true },
"username": { "description": "Identifiant de l'utilisateur.", "type": "varchar(1,30,alphanumeric)", "optional": true },
"firstname": { "description": "Prénom de l'utilisateur.", "type": "varchar(3,30,letters)", "optional": true },
"lastname": { "description": "Nom de l'utilisateur.", "type": "varchar(3,30,letters)", "optional": true },
"firstname": { "description": "Prénom de l'utilisateur.", "type": "varchar(3,30,lettersutf8)", "optional": true },
"lastname": { "description": "Nom de l'utilisateur.", "type": "varchar(3,30,lettersutf8)", "optional": true },
"mail": { "description": "Adresse mail de l'utilisateur.", "type": "mail", "optional": true },
"password": { "description": "Mot de passe de l'utilisateur.", "type": "text", "optional": true },
"status": { "description": "Status de l'utilisateur.", "type": "status", "optional": true }