OK this is what i ended up with to validate the custom profile field! this is a soft validation for canadian postal codes!
function valid_postcode ($data) {
global $bp;
$postcodecheck = $_POST['field_23'];
$regex = '/[a-z][0-9][a-z][- ]?[0-9][a-z][0-9]$/i';
if(!preg_match($regex, $postcodecheck)) {
bp_core_add_message( __( 'That Postal code is invalid. Check the formatting and try again.', 'buddypress' ), 'error' );
wp_redirect( $bp->loggedin_user->domain . 'profile/edit/group/2/' );
exit();
}elseif ($postcodecheck == '') {
bp_core_add_message( __( 'You need to fill out the Postal Code.', 'buddypress' ), 'error' );
wp_redirect( $bp->loggedin_user->domain . 'profile/edit/group/2/' );
exit();
}
return $data;
}
add_action( 'xprofile_data_before_save', 'valid_postcode');