New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should the API support field validation? #225
Comments
We can also add validation errors to payment.addEventListener('shippingaddresschange', function(evt) {
evt.updateWith(new Promise(function(resolve) {
if (payment.shippingAddress.postalCode === '99999') {
details.validationErrors = [{field: 'postalCode', message: 'Example site does not support shipping to postal code 9999'}];
} else {
delete details.validationErrors;
}
resolve(details);
}));
}); |
This is an interesting proposal but one that adds a fair amount of complexity. PR #257 added the ability to provide a free form error message describing the validation error as part of the |
closing this one as duplicate of #647 |
It would be nice if the web page could indicate a problem with specific fields provided by the user:
Examples:
I am particularly interested in checks that CAN NOT be done by the user agent on it's own. For instance the user agent could check that the state/region and postal code match, but it could not know which states/regions the web page supports shipping to.
My understanding is that currently the only way to indicate invalid fields is to:
paymentResponse.complete('fail')
That seems like a big headache for a user who just has to tweak one field.
Instead, I am proposing that the web page could indicate errors of various types. One idea of how this could work is with a new
validationErrors()
method on thePaymentResponse
object:The user agent, upon receiving these validation errors, could display a list of invalid fields along with the message for each field. The user would correct each field and then continue.
The text was updated successfully, but these errors were encountered: