Skip to content

Better Typescript validation on errorMessages #34

Open
@brophdawg11

Description

@brophdawg11

errorMessages keys should ideally be restricted to ValidityStateKey unioned with keys in customValidations.

let formDefinitions: FormSchema = {
  inputs: {
    name: {
      validationAttrs: { 
        required: true,
      },
    },
    custom: {
      customValidations: {
        isThisThingValid() { ... }
      },
      errorMessages: {
        // ✅ OK since this matches a customValidation
        isThisThingValid: () => { ... }
        // ❌ Should fail because nope is not a ValidityStateKey or a customValidation name
        nope: () => { ... }
      },
    },
  },
  errorMessages: {
    // ✅ OK since this matches a ValidityStateKey
    valueMissing: () => { ... }
    // ❌ Should fail because nope is not a ValidityStateKey or a custom validation name
    nope: () => { ... }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions