v2: выделение валидации — validate() в crud, db/queries получает готовый cidr
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user