関数
RestRouteGuards::validateCustomerAddressPayload()
Validates $_POST['customer']
fields and returns a string of error messages if any values are not valid
戻り値 戻り値
ファイル: src/Routing/RestRouteGuards.php
public function validateCustomerAddressPayload() { $mes = ''; if (WCUtils::is_blank($_POST['customer']['name1'])) { $mes .= __('Name is not correct', 'usces') . '<br />'; } if (WCUtils::is_blank($_POST['customer']['zipcode'])) { if (usces_is_required_field('zipcode')) { $mes .= __('postal code is not correct', 'usces') . '<br />'; } } else { if (!preg_match('/^[a-zA-Z0-9]+$/', $_POST['customer']['zipcode'])) { $_SESSION['usces_entry']['customer']['zipcode'] = usces_convert_zipcode($_POST['customer']['zipcode']); } if (!preg_match('/^(([0-9]{3}-[0-9]{4})|([0-9]{7}))$/', $_SESSION['usces_entry']['customer']['zipcode'])) { $mes .= __('postal code is not correct', 'usces') . '<br />'; } } if (($_POST['customer']['pref'] == __('-- Select --', 'usces') || $_POST['customer']['pref'] == '-- Select --') && usces_is_required_field('states')) { $mes .= __('enter the prefecture', 'usces') . '<br />'; } if (WCUtils::is_blank($_POST['customer']['address1']) && usces_is_required_field('address1')) { $mes .= __('enter the city name', 'usces') . '<br />'; } if (WCUtils::is_blank($_POST['customer']['address2']) && usces_is_required_field('address2')) { $mes .= __('enter house numbers', 'usces') . '<br />'; } if (WCUtils::is_blank($_POST['customer']['tel']) && usces_is_required_field('tel')) { $mes .= __('enter phone numbers', 'usces') . '<br />'; } if (!WCUtils::is_blank($_POST['customer']['tel']) && preg_match('/[^\d\-+]/', trim($_POST['customer']['tel'])) && usces_is_required_field('tel')) { $mes .= __('Please input a phone number with a half size number.', 'usces') . '<br />'; } return $mes; }