isMatch($Payment/CreditCard ,'\d{8}') = true worked for me.
If you use a custom validation (for the field on the page), it works for me
it should also be possible of course to do these kind of checks on change or on save.
Depending on how the page is opened, indeed it could be that validations are triggered immediately. In that case, what you could do is use validation when saving.
One would be
length($Payment/String) = 8
and the second would be
isMatch($Payment/String, '[0,9][0,9][0,9][0,9][0,9][0,9][0,9][0,9]')
Of course this is just a simple version of the validation. you could run all validations together (similar to this example https://academy.mendix.com/link/modules/95/lectures/822/8.3.4-Merge-Multiple-Flows)