fortress icon indicating copy to clipboard operation
fortress copied to clipboard

How to validate bigint (10 digits or more like mobile no)?

Open spurgeonbj opened this issue 9 years ago • 8 comments

Hi!

Greetings!

While validating mobile number (for 10 digits) as integer, it accepts only typical integer value (65535).

Is bigint supported? other than through regex of course.

Was also looking for date, but couldnt find.

Thank you! warm regards and gratitude for the nice framework that saves tons of work. Spurgeon

spurgeonbj avatar Jul 16 '16 09:07 spurgeonbj

Oh - interesting! Is it failing in client-side validation, or server-side?

alexweissman avatar Jul 16 '16 17:07 alexweissman

Hi Alex,

Not sure, BTW, how to check?

Validation occurs on form submit, so presume it is server side.

For now, i've used "numeric" in which '9.9' happens to be a valid mobile no!

FYI pl. Thanks!

spurgeonbj avatar Jul 16 '16 17:07 spurgeonbj

so it lets you submit the form (showing all fields as green), but then it gives an error? This would be server side, then.

BTW: with issues, you don't need salutations and signatures. Just your comment is enough.

alexweissman avatar Jul 16 '16 17:07 alexweissman

Thanks! Server side.

spurgeonbj avatar Jul 16 '16 17:07 spurgeonbj

Ok, so that would be in Valitron, which internally uses FILTER_VALIDATE_INT.

This might be platform dependent, see http://stackoverflow.com/questions/31070807/filter-var-and-validating-integer-values. One thing that could be done is to explicitly set the minimum and maximum range for integers in the call to filter_var. See http://php.net/manual/en/filter.filters.validate.php.

alexweissman avatar Jul 16 '16 20:07 alexweissman

Thanks for saving my day!

On Sun, Jul 17, 2016 at 1:48 AM, Alex Weissman [email protected] wrote:

Ok, so that would be in Valitron, which internally uses FILTER_VALIDATE_INT https://github.com/vlucas/valitron/blob/master/src/Valitron/Validator.php#L223-L226 .

This might be platform dependent, see http://stackoverflow.com/questions/31070807/filter-var-and-validating-integer-values. One thing that could be done is to explicitly set the minimum and maximum range for integers in the call to filter_var. See http://php.net/manual/en/filter.filters.validate.php.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/userfrosting/fortress/issues/11#issuecomment-233149046, or mute the thread https://github.com/notifications/unsubscribe-auth/AGbU2XA6qnW88aoJyfx8J0dKDfPUOvWlks5qWTyrgaJpZM4JN-Tk .

spurgeonbj avatar Jul 17 '16 13:07 spurgeonbj

No problem - were you able to fix it? I wonder if Valitron would consider adding explicit values for min_range and max_range.

alexweissman avatar Jul 17 '16 15:07 alexweissman

Not yet.. using 'numeric' for now. will work on this and keep you posted.. :-)

spurgeonbj avatar Jul 17 '16 15:07 spurgeonbj