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

custom validation tags with constraints specified in the spec. #487

Open
nguyen0096 opened this issue Jun 24, 2024 · 1 comment
Open

custom validation tags with constraints specified in the spec. #487

nguyen0096 opened this issue Jun 24, 2024 · 1 comment
Labels
question Further information is requested

Comments

@nguyen0096
Copy link

Currently, for example, I put tag maxLength:"3", Huma will validate to input Body and also put a text in spec to indicate the constraint.

image

I can add validation logic with Resolve method but is there anyway that I can:

  • Pre-configure the validation logic and just adding tag to model, instead of defining Resolve method for all input models.
  • Put another text in the position of <= 3 characters as in the image, instead of putting it into description.

Thanks! You guys created a great repository btw.

@danielgtaylor danielgtaylor added the question Further information is requested label Aug 19, 2024
@danielgtaylor
Copy link
Owner

@nguyen0096 this isn't currently possible:

  1. There is no way to link custom tags with custom validation logic right now. This is a feature we could consider adding or enabling it to be added by others easily by hooking into the validation phase of the request.
  2. The <= 3 characters text is generated by the documentation tool based on the JSON Schema which has a field like "minimum": 3 within it. I don't think you can modify this easily but I'm not sure, take a look at https://github.com/stoplightio/elements. You can also consider different documentation tools, see https://huma.rocks/features/api-docs/#customizing-documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants