inbo / whip

✅ Human and machine-readable syntax to express specifications for data
MIT License
7 stars 0 forks source link

Questions about numberformat #7

Open peterdesmet opened 7 years ago

peterdesmet commented 7 years ago
  1. Does the format need to be a number, or is this also valid:
length:
  numberformat: .2   # test for "a.ab"
  1. Does the format need to be expressed in quotes?
length:
  numberformat: '.2'  # are the quotes necessary?
  1. Can the numberformat handle comma decimal points?
length:
  numberformat: ',2'  # test for "1,23"
  1. Can the numberformat handle more formats?
length:
  numberformat: '1,3.2'  # test for "1,000.00"
stijnvanhoey commented 7 years ago

I see two elements: (1) is it currently implemented in the validator and (2) do we want it - in general - as a whip specification

  1. # test for "a.ab". (1) no, the validator matches regex on numbers [0-9] only, (2) As the numberformat is called numberformat, I would keep it as such and not extend the support towards non-numbers.

  2. Does the format need to be expressed in quotes? (1) yes, otherwise the schema will not be valid (SchemaError: {'decimallatitude': [{'numberformat': ["must be of ['string'] type"]}]}(2) I would keep it as such, simplifies the yaml intepretation.

  3. Can the numberformat handle comma decimal points? (1) No, currently only dots support provided (2) if general good practice is to use dots for decimal number, I would stick to that and not extend support for bad practices.

  4. Can the numberformat handle more formats? (1) No, (2) If really on the wish-list, it could become an implementation requirement.

peterdesmet commented 7 years ago

Ok for all points, but would be more consistent if quotes are not required. See all rules above numberformat: with or without quotes doesn't matter, except for regex, and the user is not aware that this is regex behind the scene.