When I looked into the implementation of java.util.UUID.fromString
, I found that it doesn\'t check for the UUID length. Is there any particular reason for this?
Only the original authors of the UUID class could tell you why they chose not to check the component lengths in the fromString method, but I suspect they were trying to heed Postel's law:
Be liberal in what you accept, and conservative in what you send.
You can always check the input against a regular expression like this one:
[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}