[TYPO3-team-core-v5] Validation: should '123' be considered a valid float?

Martin Kutschker masi-no at spam-typo3.org
Mon Nov 17 22:10:04 CET 2008


Karsten Dambekalns schrieb:
> Hi.
> 
> I have been musing about validation. Problem is, we cannot simply use
> is_float(), is_integer() to check those two types - everything we get
> from the browser or command line is a string. So we need to handle
> numbers in strings. Ok, fine.
> 
> But there's a philosophical^W^Wanother point to the story: Imagine a
> "Weight Watchers" website. You need to enter your weight. The argument
> has been assigned a "float" validator.
> 
> You enter  |  Valid?
>   87.5     |    Yes
>   68.0     |    Yes
>   100      |     No
> 
> Now, technically this might get a nod. But as a user you'd be stumped.
> Right? I mean, every kid knows 100 is the same as 100.0 or 100.00.

It depends where the input comes from. If you would validate machine
input (read from a file, got via JSON or SOAP) 100 is not a float, but
of course when the comes input from a human it is a float. And depending
on the local it would use perhaps a "," instead of the ".".

But I guess that you would of course apply an input transformation to
the users's input before making the final validation. Mind that can lead
to misleading error messages, so validation working on the human display
format would be a nice thing.

Masi


More information about the TYPO3-team-core-v5 mailing list