v2: выделение валидации — validate() в crud, db/queries получает готовый cidr

This commit is contained in:
2026-06-13 07:11:53 +04:00
parent 3c061b6c4b
commit fe5a7d0d37
4 changed files with 10 additions and 9 deletions
+3 -5
View File
@@ -4,7 +4,7 @@
// ═══════════════════════════════════════════════════════════════════════════════
const { pool } = require('./index');
const { validate, overlaps } = require('../validators');
const { overlaps } = require('../validators');
// ── Компании ──────────────────────────────────────────────────────────────────
@@ -48,8 +48,7 @@ async function listEntries(companyId, includeDeleted = false) {
/**
* Создать запись (с валидацией, проверкой лимита и пересечений).
*/
async function createEntry(companyId, rawValue, comment, userEmail, impersonatedBy) {
const { cidr, wasNormalized } = validate(rawValue);
async function createEntry(companyId, cidr, comment, userEmail, impersonatedBy, wasNormalized = false) {
const client = await pool.connect();
try {
await client.query('BEGIN');
@@ -95,8 +94,7 @@ async function createEntry(companyId, rawValue, comment, userEmail, impersonated
/**
* Обновить запись.
*/
async function updateEntry(entryId, companyId, rawValue, comment, userEmail, impersonatedBy) {
const { cidr, wasNormalized } = validate(rawValue);
async function updateEntry(entryId, companyId, cidr, comment, userEmail, impersonatedBy, wasNormalized = false) {
const client = await pool.connect();
try {
await client.query('BEGIN');