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
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 822
Download (untitled) / with headers
text/plain 822b
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.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-14824-1265830834-147.54460-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
From: dstahlke [...] gmail.com
X-RT-Original-Encoding: utf-8
Content-Length: 327
Download (untitled) / with headers
text/plain 327b
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.
MIME-Version: 1.0
In-Reply-To: <rt-3.8.HEAD-14824-1265830834-147.54460-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <rt-3.8.HEAD-14824-1265830834-147.54460-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-14818-1265831562-1869.54460-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
From: dstahlke [...] gmail.com
X-RT-Original-Encoding: utf-8
Content-Length: 381
Download (untitled) / with headers
text/plain 381b
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]* )?.
MIME-Version: 1.0
In-Reply-To: <rt-3.8.HEAD-14818-1265831562-1869.54460-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <rt-3.8.HEAD-14824-1265830834-147.54460-0-0 [...] rt.cpan.org> <rt-3.8.HEAD-14818-1265831562-1869.54460-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-14826-1265832628-401.54460-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
From: dstahlke [...] gmail.com
X-RT-Original-Encoding: utf-8
Content-Length: 551
Download (untitled) / with headers
text/plain 551b
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.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.