Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Omit on a type, tsoa ignores regex pattern validation on field in that type #1543

Closed
2 of 4 tasks
netofri opened this issue Jan 17, 2024 · 1 comment
Closed
2 of 4 tasks

Comments

@netofri
Copy link

netofri commented Jan 17, 2024

Using Omit on a type that includes a field that is a string with a regex pattern, tsoa ignores the regex pattern validation, and validates only that the value is a string.

Sorting

  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn't already been submit

Steps to Reproduce

Given a regex pattern type, e.g. UUID type from the tsoa docs:

/**
 * Stringified UUIDv4.
 * See [RFC 4112](https://tools.ietf.org/html/rfc4122)
 * @pattern [0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}
 * @format uuid
 */
type UUID = string;

And types:

type User = {
  id: UUID;
  omittedField: number;
}

type CreateUser = Omit<User, 'omittedField'>;

Expected Behavior

Using CreateUser as the type of a request body, tsoa should validate that the id field string value matches the regex pattern.

Current Behavior

Using CreateUser on the request body of a request, tsoa only validates that the id field is a string, but does NOT validates the regex pattern.

Context (Environment)

Version of the library: 6.0.1
Version of NodeJS: 16.17.0

  • Confirm you were using yarn not npm: [ i used npm ]
@netofri netofri changed the title Using Omit on a type, removes regex pattern validation from field in the type Using Omit on a type, tsoa ignores regex pattern validation on field in that type Jan 17, 2024
@WoH
Copy link
Collaborator

WoH commented Jan 17, 2024

Dup #1531

@WoH WoH closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants