Skip to content
Snippets Groups Projects
Commit 9a49344c authored by Florian Azizian's avatar Florian Azizian
Browse files

FIX #210 improve check for duration_current_use

parent 8eef8352
No related branches found
No related tags found
No related merge requests found
......@@ -269,7 +269,8 @@
<div class="col-sm-6">
<mat-form-field>
<input matInput [(ngModel)]="currentType.duration_current_use" name="duration_current_use" id="duration_current_use" title="{{lang.durationCurrentUse}}"
type="number" placeholder="{{lang.durationCurrentUse}}" pattern="^[0-9]*$">
type="text" placeholder="{{lang.durationCurrentUse}}" pattern="^[0-9]*$">
<!-- pattern without required attribute must be type text -->
</mat-form-field>
</div>
</div>
......
......@@ -90,6 +90,9 @@ class DoctypeController
if (!empty($errors)) {
return $response->withStatus(500)->withJson(['errors' => $errors]);
}
if (empty($data['duration_current_use'])) {
$data['duration_current_use'] = null;
}
$data = DoctypeController::manageValue($data);
$secondLevelInfo = SecondLevelModel::getById(['select' => ['doctypes_first_level_id'], 'id' => $data['doctypes_second_level_id']]);
......@@ -166,6 +169,9 @@ class DoctypeController
if (!empty($errors)) {
return $response->withStatus(500)->withJson(['errors' => $errors]);
}
if (empty($data['duration_current_use'])) {
$data['duration_current_use'] = null;
}
$data = DoctypeController::manageValue($data);
$secondLevelInfo = SecondLevelModel::getById(['select' => ['doctypes_first_level_id'], 'id' => $data['doctypes_second_level_id']]);
if (empty($secondLevelInfo)) {
......@@ -371,6 +377,11 @@ class DoctypeController
$aArgs['delay2'] < 0) {
$errors[]= 'Invalid delay2 value';
}
if (Validator::notEmpty()->validate($aArgs['duration_current_use']) &&
(!Validator::intVal()->validate($aArgs['duration_current_use']) ||
$aArgs['duration_current_use'] < 0)) {
$errors[]= 'Invalid duration_current_use value';
}
return $errors;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment