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

fix: schema-based validation not working #1155

Closed
seriousManual opened this issue Jun 30, 2021 · 10 comments
Closed

fix: schema-based validation not working #1155

seriousManual opened this issue Jun 30, 2021 · 10 comments
Labels
status: wontfix type: fix Issues describing a broken feature.

Comments

@seriousManual
Copy link

We have been trying to use the schema based validation as described in the following sample:
https://github.com/typestack/class-validator/tree/develop/sample/sample5-schemas

We were not able to get the schema based validation to work and even executing the code from the provided sample did not work.

This looks like there has been a regression somewhere in the past?

@seriousManual seriousManual added status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature. labels Jun 30, 2021
@pasear
Copy link

pasear commented Oct 26, 2021

Same here.
Here's a simple script to reproduce it.

var classValidator = require("class-validator");

var classValidatorSchemas = [
  { name: "uuid", properties: { value: [{ type: "isUuid", constraints: [4] }] } },
  { name: "len", properties: { value: [{ type: "maxLength", constraints: [1] }] } },
  { name: "mail", properties: { value: [{ type: "isEmail" }] } }
];

classValidatorSchemas.forEach((s) => classValidator.registerSchema(s));

console.log("uuid", classValidator.validateSync("uuid", {value: "aaa"}));
console.log("len", classValidator.validateSync("len", {value: "aaa"}));
console.log("mail", classValidator.validateSync("mail", {value: "aaa"}));

@d-otter
Copy link

d-otter commented Nov 3, 2021

The schema-based validation stopped working with version 0.12.0 - same issue, unfortunately I do not know the internals good enough to spot the root cause

@jbeckton
Copy link

Looks like Schema Based validation will be deprecated in 1.0 #178.

Bummer

@braaar
Copy link
Member

braaar commented Oct 6, 2022

If you want schema based validation, check out the zod readme's comparison with other validators

@pasear
Copy link

pasear commented Oct 6, 2022 via email

@braaar
Copy link
Member

braaar commented Oct 6, 2022

It is currently a bug, but as this feature is going to be deprecated, it's not wise for this project to prioritise scarce maintainer time and effort towards fixing it. After almost a year of inactivity, we have gotten a little bit of maintainer involvement, and I think we will have to accept that we can't get everything we want, at least for the time being. See #1719

PR is welcome, though. The first step to fixing this would be to write some tests for the schema based validation.

@pasear
Copy link

pasear commented Oct 6, 2022 via email

@braaar
Copy link
Member

braaar commented Oct 6, 2022

How about removing it from the document? It's still on the homepage (readme) and confusing peoole. It's already broken and no need to keep it in the document.

That is a good compromise solution. I can make a PR.

@NoNameProvided NoNameProvided changed the title Schemabased validation not working fix: schema-based validation not working Nov 13, 2022
@NoNameProvided NoNameProvided added status: wontfix and removed status: needs triage Issues which needs to be reproduced to be verified report. labels Nov 13, 2022
@NoNameProvided
Copy link
Member

NoNameProvided commented Nov 13, 2022

As mentioned in the thread, schema-based validation is deprecated and will be removed. The documentation has been updated, it now contains a suggestion of what libraries to use instead of class-validator.

To clarify, class-validatior will retain the ability to serialize validation meta-data and send it over the wire, but it will be considered an internal API and one must define their "validation schema" with decorators first.

I am closing this issue as wontfix.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: wontfix type: fix Issues describing a broken feature.
Development

Successfully merging a pull request may close this issue.

6 participants