I need to to check whether the number of digits in a number are equal to some other number. The best way I could come up with was this:
require(Number.toString == """\d{8}""", throw new InvalidDateFormatException("Wrong format for string parameter"))
where the number of digits required are 8. Is there any better way?
One alternative:
require(Number.toString.length == 8, throw new InvalidDateFormatException("Wrong format for string parameter"))