-
-
Notifications
You must be signed in to change notification settings - Fork 174
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
stability of _type-field #95
Comments
It seems that #93 is related to this issue as well; maybe there is will be a common solution for both issues. |
You are welcome to use the |
#93 has been resolved and is in |
Sorry for commenting on this again, but I have a pretty similar question once again: what about getting a validator function to validate arbitrary data (not from the model)? To call the function I can do (from a live example): Ember.get(model, `validations._validators.${key}.${attr}`[index].validate(theData, theOptions); I am getting
The need to do this arises from form validation (and I don't want the form to operate on the actual, validation-possessing object at first, at least not on all fields). Should I open another issue for this? Edit. I find that I can also get a validator by using |
I definitely think that using a container lookup is better than using the |
To further elaborate on my use case: We have form fields which get told which model and attribute of that model they are going to fill in, and we want these form fields to fetch the validations from the model they are configured on (either we create the record on form display or we fetch an existing one). That all works fine so far. But. If you don't want to directly two-way-bind to a model attribute, because the user fills in a format different from the one stored (say, a date in German is dd.mm.yyyy instead of iso yyyy-mm-dd, which we want to store), you need some kind of intermediate step to translate into the format and then look at the validations from the input format and the stored format (because the stored format might have additional constraints -- we do have two validators/configs for this, then, and one is defined/mixed into the form field component, but it'd be nice to have a way to make that more flexible too -> container lookup). In short, we want to be able to translate to the stored format and arbitrarily want to check the validity before writing to the model using exactly the configuration of the validator we defined on the model. I admit that this might not be the best way to do this kind of thing, but then, I am slowly getting into that topic with ember and cp-val's (doing forms since early 2000s, and validation with its many edge cases has never been easy). I am open to suggestions though :-) |
I want to check for the type of a validator for a given attribute (to determine if there is a 'presence'-validation, to adapt css classes in a form for a given field, like, 'must be filled in'). Is it safe to use the
_type
field of a given validator for this purpose? The underscore hints at privateness or instability.How likely is this to change? Is there a better way to check?
The text was updated successfully, but these errors were encountered: