Skip to content

FEATURE: Add runtime validation for index name field #7

Description

@kalnode

The index name field is type string however we also want to restrict it to: alphanumeric, dash, underscore and dot.

Barring using a validator library like Zod (should we?), it could be a simple function like so:

export function isValidName(str:string) {
    const regex = /^[a-zA-Z\-_.]+$/
    return regex.test(str)
}

Also look into: Unknown what Strapi validation features we could leverage, especially because we use our own custom types.

This validation should be applied to:

Admin pages:

  • The HTML input field when creating an index
  • Submission of the create index API

Server:

  • Any function dealing with index name

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions