// ========================
// Device Validation

const Joi = require("joi");

// ========================
const insertDeviceSchema = Joi.object({
    device_name: Joi.string().max(100).required(),
    is_active: Joi.boolean().required(),
    brand_id:  Joi.number().integer().min(1),
    device_location: Joi.string().max(100).required(),
    device_description: Joi.string().required(),
    ip_address: Joi.string()
        .ip({ version: ['ipv4', 'ipv6'] })
        .required()
        .messages({
            'string.ip': 'IP address must be a valid IPv4 or IPv6 address'
        })
});

const updateDeviceSchema = Joi.object({
    device_name: Joi.string().max(100),
    is_active: Joi.boolean(),
    brand_id:  Joi.number().integer().min(1),
    device_location: Joi.string().max(100),
    device_description: Joi.string(),
    ip_address: Joi.string()
        .ip({ version: ['ipv4', 'ipv6'] })
        .messages({
            'string.ip': 'IP address must be a valid IPv4 or IPv6 address'
        })
}).min(1);


// ✅ Export dengan CommonJS
module.exports = {
    insertDeviceSchema, updateDeviceSchema
};