teach (someone) a lesson
idiomDefinition of teach (someone) a lesson
: to make it less likely that a person will repeat doing something bad
I'm glad they got caught. That will teach them a lesson!