export function requireString(data, field, errors, prefix = '') {
    const val = data[field];
    if (val === undefined || val === null) {
        errors.push(`Missing required string field '${prefix}${field}'`);
    }
    else if (typeof val !== 'string') {
        errors.push(`Field '${prefix}${field}' must be a string, got ${typeof val}`);
    }
    else if (val.trim() === '') {
        errors.push(`Field '${prefix}${field}' must not be empty`);
    }
}
export function requireInteger(data, field, errors, prefix = '') {
    const val = data[field];
    if (val === undefined || val === null) {
        errors.push(`Missing required integer field '${prefix}${field}'`);
    }
    else if (typeof val !== 'number' || !Number.isInteger(val)) {
        errors.push(`Field '${prefix}${field}' must be an integer, got ${typeof val === 'number' ? val : typeof val}`);
    }
}
export function requireNonEmptyArray(data, field, errors, prefix = '') {
    const val = data[field];
    if (val === undefined || val === null) {
        errors.push(`Missing required array field '${prefix}${field}'`);
        return null;
    }
    if (!Array.isArray(val)) {
        errors.push(`Field '${prefix}${field}' must be an array, got ${typeof val}`);
        return null;
    }
    if (val.length === 0) {
        errors.push(`Field '${prefix}${field}' must not be empty`);
        return null;
    }
    return val;
}
export function requireArrayOfShape(data, field, errors, itemChecker, prefix = '') {
    const arr = requireNonEmptyArray(data, field, errors, prefix);
    if (!arr)
        return;
    for (let i = 0; i < arr.length; i++) {
        itemChecker(arr[i], i, errors);
    }
}
