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 | 1497 | September 29, 2018 | |
| Using other Integer types as type parameters | 3 | 815 | December 13, 2019 | |
| What's the correct way of defining struct with an Integer Parameter? | 9 | 3808 | May 8, 2019 | |
| Adding constrain on the range of `N` in parametric types for function arguments | 6 | 537 | August 12, 2021 | |
| How to add constraints to parametric arguments | 11 | 1258 | February 14, 2021 |