Magento 2 Certification Questions List | How to convert attribute value on save

How to convert attribute value on save (e.g. from 1,2,3 to 1_2_3) taking into account the best practice, in case of invalid input exception needs be thrown?