moved validation after attachment definition