As part of a sentence, a judge in Idaho ordered that a 19-year-old convicted of statutory rape cannot have sex with anyone until he is married.

Cody Herrera pleaded guilty to statutory rape of a 14-year-old girl in March 2015 and received a sentence of five to 15 years in prison, the Times-News reports.

The judge said that if Herrera completes his celibacy requirement, he will be released early on probation.

>> Read more trending news

Before the sentencing, Herrera told the judge he’s had 34 sexual partners.

“I have never seen that level of sexual activity by a 19-year-old,” the judge said to the Times-News.

A professor told the Times-News that the judge’s celibacy sentence could be unconstitutional, and if Herrera appealed the sentence, “He would win.”

Read more at magicvalley.com.