primeng icon indicating copy to clipboard operation
primeng copied to clipboard

[KeyFilter] number and integer issue

Open ghost opened this issue 8 years ago • 3 comments

Hello

Would you please check why KeyFilter for number and integer accepts -9---989 and ----------------

is that normal or we should implement our custom number and integer validator

Thanks for the great effort

ghost avatar Mar 13 '18 12:03 ghost

Because the KeyFilter is based on regular expression testing and predefined mask for pint or int pattern is insufficiently defined.

My opinion is that this issue is bug.

jupin-r avatar Mar 13 '18 13:03 jupin-r

It is an expected behavior. Currently in default mode, typing checks the key only. If you want to validate whole value on typing, you can use pValidateOnly attribute. In addition, keyfilter with validateOnly attribute don't support default patterns such as 'int', 'num' etc. You need to write custom pattern. We'll add this to Keyfilter's documentation. Exp patterns for;

positive 'int' values: /^\d+$/ positive and negative 'int' values: /^(-?|+?)\d+$/

https://www.primefaces.org/primeng/#/keyfilter

mertsincan avatar May 10 '18 23:05 mertsincan

It is an expected behavior. Currently in default mode, typing checks the key only. If you want to validate whole value on typing, you can use pValidateOnly attribute. In addition, keyfilter with validateOnly attribute don't support default patterns such as 'int', 'num' etc. You need to write custom pattern. We'll add this to Keyfilter's documentation. Exp patterns for;

positive 'int' values: /^\d+$/ positive and negative 'int' values: /^(-?|+?)\d+$/

https://www.primefaces.org/primeng/#/keyfilter

@mertsincan so, is there any chance to apply an additional pattern when using keyfilter with validateOnly attribute? I cannot find anything in the mentioned documentation yet...

The background is: I'm trying to combine a regex keyfilter for validating an IPv4 address but in addition to that i don't want to allow any inputs except of "[0-9.]" in first place (similar to an input mask).

flawesomesoft avatar May 11 '22 14:05 flawesomesoft