Skip to content

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

Description

@vbusch

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.

Activity

  1. dtaylor113 commented on Sep 18, 2018

    @dtaylor113
    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

  2. vbusch commented on Sep 18, 2018

    @vbusch
    Author

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

  3. dtaylor113 commented on Sep 18, 2018

    @dtaylor113
    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

  4. dtaylor113 commented on Sep 18, 2018

    @dtaylor113
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions