- Improved signature 'ID' (e.g. ABC-123) parsing, closed #876

This commit is contained in:
Mark Friedrich
2019-12-06 17:38:36 +01:00
parent fafcff2c7e
commit 9ecbe33f5e
3 changed files with 9 additions and 13 deletions

View File

@@ -167,7 +167,7 @@ class SystemSignatureModel extends AbstractMapTrackingModel {
*/
protected function validate_name(string $key, string $val): bool {
$valid = true;
if(mb_strlen($val) < 3){
if(!mb_ereg('^[a-zA-Z]{3}-\d{3}$', $val)){
$valid = false;
$this->throwValidationException($key);
}

View File

@@ -142,7 +142,7 @@ define([
reason = jqXHR.statusText;
}else if(jqXHR.name){
// validation error new sig (new row data save function)
reason = jqXHR.name;
reason = jqXHR.name.msg;
// re-open "name" fields (its a collection of fields but we need "id" field)
jqXHR.name.field.$element.editable('show');
}else{
@@ -1641,11 +1641,9 @@ define([
},
validate: function(value){
let msg = false;
let mbLength = [...$.trim(value)].length; // unicode beware
if(mbLength < 3){
msg = 'Id is less than min of "3"';
}else if(mbLength > 10){
msg = 'Id is more than max of "10"';
//let mbLength = [...$.trim(value)].length; // unicode beware
if(! value.trimChars().match(/^[a-zA-Z]{3}-\d{3}$/)){
msg = 'ID format invalid. E.g.: ABC-123';
}
if(msg){

View File

@@ -142,7 +142,7 @@ define([
reason = jqXHR.statusText;
}else if(jqXHR.name){
// validation error new sig (new row data save function)
reason = jqXHR.name;
reason = jqXHR.name.msg;
// re-open "name" fields (its a collection of fields but we need "id" field)
jqXHR.name.field.$element.editable('show');
}else{
@@ -1641,11 +1641,9 @@ define([
},
validate: function(value){
let msg = false;
let mbLength = [...$.trim(value)].length; // unicode beware
if(mbLength < 3){
msg = 'Id is less than min of "3"';
}else if(mbLength > 10){
msg = 'Id is more than max of "10"';
//let mbLength = [...$.trim(value)].length; // unicode beware
if(! value.trimChars().match(/^[a-zA-Z]{3}-\d{3}$/)){
msg = 'ID format invalid. E.g.: ABC-123';
}
if(msg){