woogists
3/11/2018 - 3:56 PM

Validation

[Extending][Implementing the WC Integration Class] Validation

public function validate_api_key_field( $key, $value ) {
    if ( isset( $value ) && 20 < strlen( $value ) ) {
        WC_Admin_Settings::add_error( esc_html__( 'Looks like you made a mistake with the API Key field. Make sure it isn&apos;t longer than 20 characters', 'woocommerce-integration-demo' ) );
    }

    return $value;
}