vocdoni / ui-components

Vocdoni UI components libs
GNU General Public License v3.0
3 stars 2 forks source link

Add more functionality to the spreadsheet specs meta field #130

Closed elboletaire closed 6 months ago

elboletaire commented 7 months ago

With version 0.7.9 we added dynamic validations for the spreadsheet census strategy, allowing people creating elections to add custom validations to the input fields.

This should be improved to add more information, at least:

The current implementation uses meta.census.specs as an object of patterns as react-hook-form expects them, but it should be refactored to allow other settings (hence the name "specs"), to something like:

interface Specs {
  type: string // or maybe more specific to 'number' | 'text' | '[...]'
  pattern: {
    value: string // shall be converted to regexp (as we already do)
    message: string
  }
  description: string
  props: any // ? or maybe Record<string,any> ?
}