-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
Error Importing Validator Class #260
Comments
I've got the same issue:
|
This is probably because there is no actual class, it is just a type definition as far as I can see. @snewcomer we should probably add a dummy class? The docs regarding class based validators could also use some extra love for actual usage. I'm currently wrapping the class in a function so using them is identical to that of normal validators. |
Also I can't get it to work at all 🤔 There also don't seem to be tests present (in neither of the repositories) which check if injection of for example a service even works. |
https://github.com/poteto/ember-changeset/pull/520/files#diff-f721c38c4110379388cab513565fec56R1853 Hi all! I updated the README. It can be a plain class I assumed. Is this not the case? |
I have not fully investigated, but I think they need to be registered with the container one way or another. If you try to inject a service to a bare class it currently errors. |
I'm not sure we know how to lookup your class from the container. Our changeset is outside the purview of Ember and it's DI system. It would be nice for us to I imagine you might be able to register your validators on boot? Or is there something else I am missing? |
@snewcomer I haven't done this before in Ember but I think this is the relevant bits we'll need https://guides.emberjs.com/release/applications/dependency-injection/#toc_factory-registrations |
We would need a standard folder structure for us to know/register everything in |
Definitely. Don't we already have that though? The cli generators put stuff in validations and validators folders. |
I think the question becomes - We can certainly register all files in a validators folder (maybe |
I also found out that class-based validators are not working when using a nested changeset structure, for example
This does, however, work when using functional validators. Personally, I think this is an inconsistency and nested changesets should be able to have class-based validators. |
Also if it's currently not possible to inject a service into a class-based validator, should we at least remove |
I haven't had any luck getting a class based validator to work according to the README instructions either. |
Using version
3.8.0
of bothember-changeset
andember-changeset-validations
, I'm getting an error when importing theValidation
class for use in a class-based custom validator:Could not find module ember-changeset-validations/validator
. I have imported theValidator
class exactly as the docs say:I can't seem to find any
Validator
class within the source code and the tests for class-based validators don't seem to extend theValidator
class as well.Removing
extends Validator
(like in the tests) prevents the import error from appearing, however, the validations do not run.The text was updated successfully, but these errors were encountered: