"re-formality", controlling dynamic types for the form module is throwing an error: input must be of record type

Hey @alex.fedoseev, I am using re-formality and trying to create input and output types to be dynamic. Here’s a sample code:

type shared_input = {
  name: string,
}

type shared_output = {
  name:string
}


module Form = %form(
  type input = shared_input
  type output = shared_output

  let validators = {
    name: {
      strategy: OnSubmit,
      validate: ({name}) => {
        FormValidations.CommonValidation.validateName(name, "error_msg")
      },
    }
  }
)

but its giving me the error saying:
Screenshot 2024-07-17 at 6.01.14 PM
is there any idea, how this can be solved?

node: v18.19.1
re-formality: ^4.0.0-beta.16
rescript: ^9.1.4

PPX needs static definitions of these types to generate the actual code, so it can’t be defined dynamically.

2 Likes

Thanks @alex.fedoseev,this clarification helps and will unblock me.

1 Like