Password validation inside models


I am trying to add a password validation for my model. I have done this:

$this->add('password', new Confirmation([
     'message' => 'Password doesn\'t match confirmation',
     'with' => 'repeat_password'

But i dosent seem to work ?

I have a form with password and repeat_password, but it still says it not the same, but it should be.

What am i missing?

This should be added in your form class, when you create the password element.