resedit-cli
Version:
Command-line tool for editing Windows Resource data in executable binaries
24 lines (23 loc) • 879 B
JavaScript
export function validateIntegerValue(data, propName) {
if (typeof data !== 'number') {
throw new Error(`Invalid data: '${propName}' is not a number`);
}
if (Math.floor(data) !== data) {
throw new Error(`Invalid data: '${propName}' is numeric, but not an integer`);
}
}
export function validateStringValue(data, propName) {
if (typeof data !== 'string') {
throw new Error(`Invalid data: '${propName}' is not a string`);
}
}
export function validateStringOrIntegerValue(data, propName) {
if (typeof data === 'number') {
if (Math.floor(data) !== data) {
throw new Error(`Invalid data: '${propName}' is numeric, but not an integer`);
}
}
else if (typeof data !== 'string') {
throw new Error(`Invalid data: '${propName}' is neither a string nor a number`);
}
}