How to set Constraint of PeriodicBoundary?

I want to set a constraint on the period boundary, how can I customize it according to the suggestions of the official documentation? Is there a simple case that can help me, thank you very much.

Or maybe a custom constraint.
Very Thanks!