It is not clear to me what you are doing (please open a separate topic with an MWE if you need further help). In any case, validating in the constructor is still the recommended method.
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| Restricted parametric type | 10 | 1501 | September 29, 2018 | |
| Using other Integer types as type parameters | 3 | 816 | December 13, 2019 | |
| What's the correct way of defining struct with an Integer Parameter? | 9 | 3810 | May 8, 2019 | |
| Adding constrain on the range of `N` in parametric types for function arguments | 6 | 539 | August 12, 2021 | |
| How to add constraints to parametric arguments | 11 | 1270 | February 14, 2021 |