0 is a valid input.
0. is a valid input`.
.0 is a valid input.
It's not so surprising that
. is also a valid input. Strange, but not surprising and the value is well defined.
Note this is valid only if the character matches current locale, e.g.
. will work with the English locale but not with German locale and viceversa:
Decimal(string: ".", locale: Locale(identifier: "de")) // NaN Decimal(string: ",", locale: Locale(identifier: "de")) // Optional(0)
In short, both leading and trailing zeros can be omitted.
If you want to handle this value, I recommend to use regular expressions. Decide which formats are valid, write a regular expression for that formats and check the string with that regular expression.