example for template master device
This commit is contained in:
36
validate/device.schema.js
Normal file
36
validate/device.schema.js
Normal file
@@ -0,0 +1,36 @@
|
||||
// ========================
|
||||
// Device Validation
|
||||
|
||||
const Joi = require("joi");
|
||||
|
||||
// ========================
|
||||
const insertDeviceSchema = Joi.object({
|
||||
device_name: Joi.string().max(100).required(),
|
||||
device_status: Joi.boolean().required(),
|
||||
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),
|
||||
device_status: Joi.boolean(),
|
||||
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
|
||||
};
|
||||
Reference in New Issue
Block a user