0

Is there a way to validate currency in Hyperledger, I am aware that it is possible to validate String values using regex, but I get an error when using regex for Double data type.

Here is what gives an error, it complains about the one line in the Customer defination

participant Customer{
 o Double balance regex=/^[0-9]+(\.[0-9]{1,2})?/
}

But this works (If the data type is String instead of Double)

participant Customer{
 o String balance regex=/^[0-9]+(\.[0-9]{1,2})?/
}
Mohale
  • 2,040
  • 3
  • 17
  • 18
  • Add the error message, and also examples of valid and invalid strings – Bentaye Mar 13 '18 at 07:49
  • I don't understand what you're suggesting, please kindly explain – Mohale Mar 13 '18 at 08:02
  • You say `Here is what gives an error`, but we need to know what the error is. And if you want help with the regex, we need to know what you want to validate, so give examples. – Bentaye Mar 13 '18 at 08:04

1 Answers1

1

Regular expressions are only valid for Strings in Composer.

Double, Long or Integer fields may include an optional range expression, which is used to validate the contents of the field.

R Thatcher
  • 5,550
  • 1
  • 7
  • 15
  • Could you please share any reading material with examples of how to work with ranges? Or you can give an example if you have a short one – Mohale Mar 14 '18 at 06:56