Force password policy

Hi guys, I’m using Keycloak 19.0.3, and I’ve customized the password authentication, by extending UsernamePasswordForm, but now I want to validate the password format in server side, so, is there any way to force the application of the password policy in Java?
Thanks in advance