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

Add support for validations to pfFilterFields (filterType: text) #761

Open
vbusch opened this issue Sep 18, 2018 · 5 comments
Open

Add support for validations to pfFilterFields (filterType: text) #761

vbusch opened this issue Sep 18, 2018 · 5 comments

Comments

@vbusch
Copy link

vbusch commented Sep 18, 2018

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.

@dtaylor113
Copy link
Member

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
Copy link
Author

vbusch commented 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
Copy link
Member

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
Copy link
Author

vbusch commented Sep 18, 2018

@dtaylor113
Copy link
Member

Hi @vbusch, I see your HTML is structured as:

<div pf-toolbar id="exampleToolbar" config="toolbarConfig">

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 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.

HTH,
Dave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants