Skip Menu |

This queue is for tickets about the Kwalify CPAN distribution.

Report information
The Basics
Id: 54460
Status: new
Priority: 0/
Queue: Kwalify

People
Owner: Nobody in particular
Requestors: dstahlke [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.21
Fixed in: (no value)



Subject: more complete regexp for numbers
Here are some better regular expressions for matching numbers: validate_int: your regexp is OK because YAML doesn't seem to allow exponents for integers (or at least the ruby module doesn't allow it) validate_float: if ($data !~ m{^[+-]?\d+\.\d*([eE][-+]?\d+)?$}) { validate_number: if ($data !~ m{^[+-]?\d+(\.\d*)?([eE][-+]?\d+)?$}) { Note that the expression for validate_number will match "1e+10" which neither validate_int nor validate_float will match. I thought this may be a good way to do it since "1e+10" isn't a valid YAML number, so there is no way to know whether it should be int or float. This type of value is however output by the perl YAML writers so should be allowed by the validator in the same way that 0 and 1 are allowed for boolean even though they are not really YAML boolean values.
From: dstahlke [...] gmail.com
There are other screwy number formats allowed by YAML such as base-60 and numbers with underscores (see the table in http://en.wikipedia.org/wiki/Comparison_of_data_serialization_formats) but at least allowing exponential format numbers is a good start. That way the YAML generated by perl modules like YAML::XS will validate.
From: dstahlke [...] gmail.com
From the YAML spec version 1.2, section 10.2 (JSON schema): Definition of int: Decimal integer notation, with a leading “-” character for negative values, matching the regular expression 0 | -? [1-9] [0-9]* Definition of float: Either 0, .inf, -.inf, .nan, or scientific notation matching the regular expression -? [1-9] ( \. [0-9]* [1-9] )? ( e [-+] [1-9] [0-9]* )?.
From: dstahlke [...] gmail.com
OK, strike all that. It seems that the most nearly official spec is here: http://yaml.org/type/ Integers: [-+]?0b[0-1_]+ # (base 2) |[-+]?0[0-7_]+ # (base 8) |[-+]?(0|[1-9][0-9_]*) # (base 10) |[-+]?0x[0-9a-fA-F_]+ # (base 16) |[-+]?[1-9][0-9_]*(:[0-5]?[0-9])+ # (base 60) Floating point: [-+]?([0-9][0-9_]*)?\.[0-9.]*([eE][-+][0-9]+)? (base 10) |[-+]?[0-9][0-9_]*(:[0-5]?[0-9])+\.[0-9_]* (base 60) |[-+]?\.(inf|Inf|INF) # (infinity) |\.(nan|NaN|NAN) # (not a number) Other types such as boolean and timestamp are defined on that page as well.