azurite
Version:
An open source Azure Storage API compatible server
41 lines • 1.37 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.EdmInt32 = void 0;
class EdmInt32 {
static validate(value) {
if (typeof value === "string") {
// we need to check for non-digits other than - in the int string
// as parseInt will just return the first number it finds
if (value.toLocaleString().match(/^[+-]?\d+$/)?.length !== 1) {
throw TypeError(`Not a valid integer.`);
}
const intval = parseInt(value, 10);
if (isNaN(intval)) {
throw TypeError(`Not a valid EdmInt32 string.`);
}
return intval;
}
if (typeof value !== "number") {
throw TypeError(`Not a valid EdmInt32 string.`);
}
return value;
}
constructor(value) {
this.value = value;
this.typedValue = EdmInt32.validate(value);
}
toJsonPropertyValuePair(name) {
return [name, this.typedValue];
}
toJsonPropertyValueString(name) {
return `"${name}":${this.typedValue}`;
}
toJsonPropertyTypePair(_name, _annotationLevel, _isSystemProperty) {
return;
}
toJsonPropertyTypeString(_name, _annotationLevel, _isSystemProperty) {
return;
}
}
exports.EdmInt32 = EdmInt32;
//# sourceMappingURL=EdmInt32.js.map
;