ConfirmMatch
ConfirmMatch[expr,form] confirms that expr matches the pattern form, otherwise throwing an error to the nearest surrounding Enclose.
ConfirmMatch[expr,form,info] evaluates info and includes its value in the thrown error if expr is not confirmed.
ConfirmMatch[expr,form,info,tag] uses the specified tag for any thrown errors.
Please visit the official Wolfram Language Reference for more details and examples on core symbols.