It is not possible to write a custom Java Code inside Page-Validate method. Page-Validate method to force validation (or revalidation) of the value of all properties on the step page. The system adds a message to each clipboard property that fails validation against the restrictions in its property.
You can however do so using an edit validate rule.
You can then use a validate rule in conjunction with the edit validate rule as below: