back-end/src/tables/tables.controller.js
// validate table data. does table name exists? is it less than 2 chars? does capacity exists? is it not a number? if no errors, run next
validate table data. does table name exists. is it less than 2 chars. does capacity exists. is it not a number. if no errors, run next
validate table data . does table name exists . is it less than 2 chars . does capacity exists . is it not a number . if no errors run next
async function validateCreateTableData(req, res, next) {
    const { data } = req.body
    if (!data.table_name) {
        next({
            status: 400,
            message: "table_name is missing or empty"
        })
    }
    if (data.table_name.length < 2) {
        next({
            status: 400,
            message: "table_name is too short"
        })
    }
    if (!data.capacity) {
        next({
            status: 400,
            message: "capacity is missing or zero"
        })
    }
    if (typeof data.capacity !== "number") {
        next({
            stats: 400,
            message: "Capacity is not a number"
        })
    }
    return next()
}
async function validateCreateTableData ( req , res , next ) { const { data } = req . body if ( ! data . table_name ) { next ( { status : 400 , message : "table_name is missing or empty" } ) } if ( data . table_name . length < 2 ) { next ( { status : 400 , message : "table_name is too short" } ) } if ( ! data . capacity ) { next ( { status : 400 , message : "capacity is missing or zero" } ) } if ( typeof data . capacity !== "number" ) { next ( { stats : 400 , message : "Capacity is not a number" } ) } return next ( ) }
validate table data.
validate table data .