kopia lustrzana https://github.com/OpenDroneMap/NodeODM
Added enum data type
rodzic
7f62e52c66
commit
f0a8f7665d
|
@ -95,7 +95,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(values.choices)){
|
if (Array.isArray(values.choices)){
|
||||||
type = "string"; // TODO: change to enum
|
type = "enum";
|
||||||
domain = values.choices;
|
domain = values.choices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,6 +148,9 @@ module.exports = {
|
||||||
},
|
},
|
||||||
'path': function(value){
|
'path': function(value){
|
||||||
return value; // No conversion needed
|
return value; // No conversion needed
|
||||||
|
},
|
||||||
|
'enum': function(value){
|
||||||
|
return value; // No conversion needed
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -202,11 +205,13 @@ module.exports = {
|
||||||
return true; // All strings/paths are fine
|
return true; // All strings/paths are fine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: handle enum
|
|
||||||
];
|
];
|
||||||
|
|
||||||
let checkDomain = function(domain, value){
|
let checkDomain = function(domain, value){
|
||||||
|
if (Array.isArray(domain)){
|
||||||
|
// Special case for enum checks
|
||||||
|
if (domain.indexOf(value) === -1) throw new Error(`Invalid value ${value} (not in enum)`);
|
||||||
|
}else{
|
||||||
let matches,
|
let matches,
|
||||||
dc = domainChecks.find(dc => matches = domain.match(dc.regex));
|
dc = domainChecks.find(dc => matches = domain.match(dc.regex));
|
||||||
|
|
||||||
|
@ -215,6 +220,7 @@ module.exports = {
|
||||||
}else{
|
}else{
|
||||||
throw new Error(`Domain value cannot be handled: '${domain}' : '${value}'`);
|
throw new Error(`Domain value cannot be handled: '${domain}' : '${value}'`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Scan through all possible options
|
// Scan through all possible options
|
||||||
|
|
File diff suppressed because one or more lines are too long
Ładowanie…
Reference in New Issue