import QueryError from "../../errors/QueryError.js";
export function requireNonEmptyString(value, field, errorCode) {
    if (typeof value !== 'string' || value.trim().length === 0) {
        throw new QueryError(`${field} must be a non-empty string`, {
            code: errorCode,
            context: { field },
        });
    }
    return value.trim();
}
export function freezeStringList(values, field, errorCode) {
    if (!Array.isArray(values)) {
        throw new QueryError(`${field} must be an array`, {
            code: errorCode,
            context: { field },
        });
    }
    const normalized = [];
    for (const value of values) {
        normalized.push(requireNonEmptyString(value, field, errorCode));
    }
    return Object.freeze([...new Set(normalized)].sort());
}
