import type { Fields } from "../../../types"
import type { Columns } from "../types"

export const findUnmatchedRequiredFields = <T extends string>(fields: Fields<T>, columns: Columns<T>) => {
  // Get all required fields
  const requiredFields = fields
    .filter((field) => field.validations?.some((validation: any) => 
      validation.rule === "required" || validation.required === true
    ))
  
  // Find which required fields are not matched in columns
  return requiredFields
    .filter((field) => columns.findIndex((column) => "value" in column && column.value === field.key) === -1)
    .map((field) => field.key) || []
}
