isValid returning false every time

i have this problem where every time i try to use isValid, it always returns false, even when it would be valid.
here’s where i think the problem is:

it keep’s on saying “variable not in scope”, plus here is where i use the function:

can someone help please?