@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
37 lines (36 loc) • 1.03 kB
JavaScript
export const xmlNumberTypesStrList = [
'byte',
'decimal',
'int',
'integer',
'long',
'negativeInteger',
'nonNegativeInteger',
'nonPositiveInteger',
'positiveInteger',
'short',
'unsignedLong',
'unsignedInt',
'unsignedShort',
'unsignedByte',
'double'
];
export const xmlStringTypesStrList = ['string'];
export const xmlDatetimeTypesStrList = ['date', 'dateTime'];
export const xmlTypesStrList = [
...xmlNumberTypesStrList,
...xmlStringTypesStrList,
...xmlDatetimeTypesStrList
];
export function isStringNumeric(str) {
return str.trim().length > 0 && !isNaN(Number(str)); // ensure strings of whitespace fail or mixed chars and numbers like '2n'
}
export function isString(attributeType) {
return xmlStringTypesStrList.includes(attributeType);
}
export function isNumber(attributeType) {
return xmlNumberTypesStrList.includes(attributeType);
}
export function isDate(attributeType) {
return xmlDatetimeTypesStrList.includes(attributeType);
}