<script>
import { ref, computed } from 'vue';

const createColumnType = (name, type, validationFunction = null) => {
  return {
    name: name,
    type: type,
    validationFunction: validationFunction,
  };
}

export const columnTypes = {
  string: createColumnType('string', 'string'),
  number: createColumnType('number', 'number'),
  boolean: createColumnType('boolean', 'boolean'),
  date: createColumnType('date', 'date'),
  datetime: createColumnType('datetime', 'datetime'),
  time: createColumnType('time', 'time'),

  // Add more column types as needed
  registration_number: createColumnType('registration_number', 'string', (value) => {
    // Require no spaces, between 1 and 12 letters and numbers
    return /^[A-Za-z0-9]{1,12}$/.test(value);
  }),
  product: createColumnType('product', 'number', (value) => {
    // Require a number between 0 and 999999
    return /^[0-9]{1,6}$/.test(value);
  }),
}
</script>