validation.js 613 Bytes
exports.checkRequiredExist = (list, required) => {
    try {
        for (let key of required) {
            if (typeof list[key] === 'undefined' || list[key] === null) {
                return key
            }
        }
        return false
    } catch (error) {
        throw error
    }
}

exports.setValues = (bucket, keys) => {
    let result = { }
    try {
        for (let key of keys) {
            if (typeof bucket[key] !== 'undefined' && bucket[key] !== null) {
                result[key] = bucket[key]
            }
        }
        return result
    } catch (error) {
        throw error
    }
}