This probably has to be done at runtime. I would consider the cost of this error-checking reasonable because someone should not be setting range constraints in a hot loop. It would be ideal to check this at compile time for developer ergonomics, but that is impossible.
An example would be that setting an integer range for a boolean makes no sense. Reference: osrf/ros2_test_cases#1014 (comment)