export default function Member(id, node) {
    let idTraits = {
        firstWord: "MEMBER",
        length: 2
    }

    let fields = [
        "firstName",
        "lastName",
        "email",
        "password"
    ]

    let checkID = () => {
        let split = id.split("-")
        return (
            split.length === idTraits.length
            && split[0] === idTraits.firstWord
            && !isNaN(Number(split[1]))
        )
    }
    let idres = checkID()
    if(!idres) {
        return false
    }

    let checkFields = () => {
        for(let i = 0; i < fields.length; i++) {
            if(!node[fields[i]]) {
                throw new Error(`Member ${node.email} is missing trait ${fields[i]}`)
                return false
            } else {
                return true
            }
        }
    }
    let fieldres = checkFields()
    if(!fieldres) {
        return false
    }

    return true
}