Instead of copy-pasting most of the code, you could just add the second validation in a branch:

    #set ($field.validate.mandatory = {'failureMessage' : $services.localization.render('core.validation.required.message')})