Hot to use Invalid() with 'same'

Probably a dumb question but I’m coding a frontend form and I have the classic password and repeat password inputs.

In the controller I then validate all the fields and I was wondering what’s the correct way to use the same validator in combination with the invalid() function.

I have validation rules set up for a few other things but I can’t find in the docs how to use the same validator to check the two values against each other.

$rules = [
    'email'     => ['required', 'email'],
    'fname'     => ['required', 'minLength' => 2],
    'lname'     => ['required', 'minLength' => 2],
    'company'   => ['required'],
    'password'  => ['required', 'minLength' => 8],
    'passcheck' => ['required'],

Just guessing, but can’t you do

'passcheck' => ['required', 'same' => get('password')],