Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation expression for floating point numbers? #6

Open
msrocka opened this issue Dec 9, 2015 · 8 comments
Open

Validation expression for floating point numbers? #6

msrocka opened this issue Dec 9, 2015 · 8 comments

Comments

@msrocka
Copy link

msrocka commented Dec 9, 2015

Is there a way to describe that a column contains plain floating point numbers (except by using a regex pattern)? There is a positiveInteger validation expression so I would expect that there is also something like decimal or double but could not find it.

Thank you

@DavidUnderdown
Copy link
Contributor

There isn't at present (nor had it been slated for inclusion in 1.1 which is just being worked on). However, I did just realise today that we may have a forthcoming project for which it would be useful.

@DavidUnderdown
Copy link
Contributor

I forgot yesterday that the Range Expression takes a Numeric Literal, which allows decimals. No expression allows exponent (aka scientific) notification however. In CSV Schema 1.0 range must have both and upper and lower bound, in the forthcoming CSV Schema 1.1 you will be able to specify only a lower, or only an upper bound. Similar to the Length Expression, the end of the range that is not to be bounded will be represented by an asterisk, ie range(20.5,) would indicate that the value in that column must be at least 20.5, while range(,20.5) would indicate that the column value must be at most 20.5.

@msrocka
Copy link
Author

msrocka commented Dec 13, 2015

@DavidUnderdown Thank you for your answers. I like the extension of the range expression.

@DavidUnderdown
Copy link
Contributor

Looking over the full EBNF, we have a Positive Integer Expression, and a PositiveIntegerLiteral: but while we have a Numeric literal there is no Numeric Expression to allow a simple check that a column holds a real number expressed as a decimal. Range will take such values, so the Numeric Expression would be useful to allow a check that the data is of the correct type before trying the range (or we may want to have the range when it is numeric, and some other check, such as is("N/A") when the column has a non-numeric value). I'll see if we can get this in to 1.1

@DavidUnderdown DavidUnderdown added this to the 1.1 milestone Dec 14, 2015
@DavidUnderdown DavidUnderdown removed this from the 1.1 milestone Jan 29, 2016
@DavidUnderdown
Copy link
Contributor

Sorry, we didn't get this into 1.1, but hopefully using range covers most of the necessary functionality. I'll leave this open for now.

@marceloverdijk
Copy link

marceloverdijk commented Apr 29, 2021

I'm looking for this as well. Best way currently to use a regexp? (e.g. regex("[0-9]*\.?[0-9]+"))

@DavidUnderdown
Copy link
Contributor

That, or use of range as described above

@marceloverdijk
Copy link

Thx @DavidUnderdown for confirming.
I must say I like the spec for validating some csv exports I have. I'm just wondering if the spec is still being actively worked on (1.2)?
My schema's are now full of regex's, which could be easily implemented with - better readable - Numeric Expression if they would be available.
Similar as positiveInteger it would be great to have integer, negativeInteger, decimal, positiveDecimal, negativeDecimal expressions being added to the spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants