[ ] bug report => search github for a similar issue or PR before submitting
[X] feature request
[ ] support request
Current behavior
In order to put in custom validation, one needs to put in a validation object in the FormlyFieldConfig, as in this example which references validators declared in the for root. It would be nice if we could put in custom validation based on options in the templateOptions and the type. I'll explain further...
Expected behavior
[N.B. part of this is motivated by the fact that we're trying to migrate over from formly for angular.js and changing the structure of how we store our forms in our database could be dangerous or require a prohibitive amount of manual work and care for our clients]
Let's say I've defined a textArea custom formly type. It might have some wrappers associated with the type and it has its own custom way it's displayed. We'd like to be able to store a number in the template options called "maxWordCount" and enforce that all textArea fields with maxWordCount of n (say n=10) are validated so that they have at most 10 words. If they have more than that, we may even want to show a message like "This field may have no more than 10 words" that depends on what's stored in the template options as well.
Minimal reproduction of the problem with instructions
I don't believe this is applicable to feature requests.
What is the motivation / use case for changing the behavior?
Part of the motivation is to have this work for our existing form JSON so that our forms stay the same for our clients who have spent a good deal of time customizing them. I also think this could be a cleaner way of storing this kind of functionality. Not having to attach all of the validators when they could be mostly inferred from the type.
Please tell us about your environment:
We develop all on Macs. Our app has historically been Angular.JS but we're updating part of it to use Angular8 and ngx-formly. We use MongoDB. I can provide more details as relevant.
Angular version: 2.0.X
I think we're on the most recent version. 8.0.3 maybe?
We support chrome, firefox, IE11. We try to support all major browsers.
I don't know that this applies as I believe this feature does not yet exist.
I'm submitting a ...
Current behavior In order to put in custom validation, one needs to put in a validation object in the FormlyFieldConfig, as in this example which references validators declared in the for root. It would be nice if we could put in custom validation based on options in the templateOptions and the type. I'll explain further...
Expected behavior [N.B. part of this is motivated by the fact that we're trying to migrate over from formly for angular.js and changing the structure of how we store our forms in our database could be dangerous or require a prohibitive amount of manual work and care for our clients] Let's say I've defined a textArea custom formly type. It might have some wrappers associated with the type and it has its own custom way it's displayed. We'd like to be able to store a number in the template options called "maxWordCount" and enforce that all textArea fields with maxWordCount of n (say n=10) are validated so that they have at most 10 words. If they have more than that, we may even want to show a message like "This field may have no more than 10 words" that depends on what's stored in the template options as well.
Minimal reproduction of the problem with instructions I don't believe this is applicable to feature requests.
What is the motivation / use case for changing the behavior? Part of the motivation is to have this work for our existing form JSON so that our forms stay the same for our clients who have spent a good deal of time customizing them. I also think this could be a cleaner way of storing this kind of functionality. Not having to attach all of the validators when they could be mostly inferred from the type.
Please tell us about your environment: We develop all on Macs. Our app has historically been Angular.JS but we're updating part of it to use Angular8 and ngx-formly. We use MongoDB. I can provide more details as relevant.
We support chrome, firefox, IE11. We try to support all major browsers.
I don't know that this applies as I believe this feature does not yet exist.