You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for validations to pfFilterFields (filterType: text) #761
Using pfFilter, and would like to be able to add validation to a filterType: 'text' field. Either be able to add a custom directive or pfValidation to pfFilter.fields
Our use case is, any value that is a legal regular expression is valid.
Hi @vbusch, can you please provide a real world example of the type of validation(s) you are looking for? Thanks, it will help me understand what you are looking for.
Thanks,
Dave
@dtaylor113, we are using the filter to filter a very large list(pf-list-view) of potentially 1000,000 items. We provide them 2 ways to filter. The first is by type, and we are using filterType=select, which works great.
They also want to be able to filter by name. And in order for it to be flexible enough, we need to allow them to search for 'queueA*' or 'queue*small', which would return queueA1, queueA2, queue1small, queue2small etc.
The actual validation we are using on the name is ensuring "new RegExp(filter.value)" doesn't throw an exception. If they enter something like '**A', or any value that the RegExp can't handle, we want the user to receive a validation exception in the normal fashion (input field, outlined in red, with an error message).
Unfortunately, we do not have the filter validation you are looking for. We could possibly investigate adding it to angular-patternfly v4, but it is unlikely we would be able to add it to the older angular-patternlfy v3.
You could look into customizing the angular-patternfly v3 Filter components and add the validation you require. The v3 filter components are located here. You could copy the source code into your own custom package. It would require adding classes hasError and help-block, and form field $error processing like I recently added here. You would probably need to add it to v3 FilterFields html.
Activity
dtaylor113 commentedon Sep 18, 2018
Hi @vbusch, can you please provide a real world example of the type of validation(s) you are looking for? Thanks, it will help me understand what you are looking for.
Thanks,
Dave
vbusch commentedon Sep 18, 2018
@dtaylor113, we are using the filter to filter a very large list(pf-list-view) of potentially 1000,000 items. We provide them 2 ways to filter. The first is by type, and we are using filterType=select, which works great.
They also want to be able to filter by name. And in order for it to be flexible enough, we need to allow them to search for 'queueA*' or 'queue*small', which would return queueA1, queueA2, queue1small, queue2small etc.
The actual validation we are using on the name is ensuring "new RegExp(filter.value)" doesn't throw an exception. If they enter something like '**A', or any value that the RegExp can't handle, we want the user to receive a validation exception in the normal fashion (input field, outlined in red, with an error message).
dtaylor113 commentedon Sep 18, 2018
Hi @vbusch, thank you for the example. Can you provide a link to some code illustrating how/where you use "new RegExp(filter.value)"? -thanks
vbusch commentedon Sep 18, 2018
@dtaylor113 I would like to add a validator to line 249 in https://github.com/vbusch/enmasse/blob/console-1626/agent/www/components/addresses/addresses_ctrl.js#L243-L262
The current validation is:
https://github.com/vbusch/enmasse/blob/console-1626/agent/www/components/addresses/addresses_ctrl.js#L213-L219
The html can be found https://github.com/vbusch/enmasse/blob/console-1626/agent/www/components/addresses/addresses.html
Let me know, if you would like me to extract the code into something easier to run.
dtaylor113 commentedon Sep 18, 2018
Hi @vbusch, I see your HTML is structured as:
Which indicates that you are using the older angular-patternfly v3. The current version of angular-patternfly is v4 where we have changed all attribute directives to component tags (see
Angular PatternFly 4 Migration Guide: Directive to Component Re-factor
Unfortunately, we do not have the filter validation you are looking for. We could possibly investigate adding it to angular-patternfly v4, but it is unlikely we would be able to add it to the older angular-patternlfy v3.
You could look into customizing the angular-patternfly v3 Filter components and add the validation you require. The v3 filter components are located here. You could copy the source code into your own custom package. It would require adding classes
hasErrorandhelp-block, and form field$errorprocessing like I recently added here. You would probably need to add it to v3 FilterFields html.HTH,
Dave