UNPKG

agentsqripts

Version:

Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems

25 lines (21 loc) 875 B
function validateUser(user) { if (!user.name) throw new Error('Name required'); if (!user.email) throw new Error('Email required'); user.name = user.name.trim(); user.email = user.email.toLowerCase(); return user; } function validateProduct(product) { if (!product.name) throw new Error('Name required'); if (!product.price) throw new Error('Price required'); product.name = product.name.trim(); product.price = parseFloat(product.price); return product; } function validateOrder(order) { if (!order.items) throw new Error('Items required'); if (!order.total) throw new Error('Total required'); order.items = order.items.filter(i => i.qty > 0); order.total = parseFloat(order.total); return order; }