> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: getValidationViolations(options: Options, context: Context) # Method package: wixEcom # Method menu location: wixEcom --> EcomValidations --> getValidationViolations # Method Link: https://dev.wix.com/docs/velo/events-service-plugins/e-commerce/service-plugins/ecom-validations/get-validation-violations.md # Method Description: Retrieves any validation violations in a site visitor's cart or checkout. The `getValidationViolations` function validates a site visitor's cart or checkout and returns any validation violations. Site visitors can see the validation violations in their cart and checkout pages. If there aren't any validation violations, the endpoint returns an object containing an empty list. The function is automatically called by Wix eCommerce when certain actions are performed on a cart or checkout. For example, when an item is added to a cart, or when a coupon is added to a checkout. The function returns a list of violations that include where the violation should be displayed and its severity, as well as a description of the violation. The description may only contain HTTP or HTTPS links created with an [anchor element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a). >**Note:** By default, the Validations service plugin only validates a site visitor's checkout. If you want to also validate a site visitor's cart, set the `validateInCart` parameter to `true` in the service plugin's config file. ### Where to find `getValidationViolations()` When you [add the Validations service plugin](https://dev.wix.com/docs/develop-websites/articles/code-tutorials/wix-e-commerce-stores/tutorial-validations-custom-extension.md#step-1-create-a-new-validation-extension), a folder is automatically added to your site. Use the `.js` file in the folder to write the code to determine which validation violations to retrieve. For more information on customizing your checkout validations plugin, see [Tutorial: Validations Service Plugin](https://dev.wix.com/docs/develop-websites/articles/code-tutorials/wix-e-commerce-stores/tutorial-validations-custom-extension.md). # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Get Validation Violations ```javascript const goldRingItemId = "37e5db61-d37d-442d-1bf5-ae755f82020b"; export const getValidationViolations = async (options, context) => { const lineItems = options.validationInfo.lineItems; let violations = []; if (hasExcessiveGoldRingQuantity(lineItems)) { const source = options.sourceInfo.source; const severity = getSourceSeverity(source); const target = { lineItem: { name: 'LINE_ITEM_DEFAULT', _id: findGoldRingLineItemId(lineItems) } }; const description = "You can't purchase more than 5 gold rings."; const violation = createViolation(severity, target, description); violations.push(violation); } return { violations }; }; function getSourceSeverity(source) { if (source === 'CART') { return 'WARNING'; } else { return 'ERROR'; } } function hasExcessiveGoldRingQuantity(lineItems) { for (const lineItem of lineItems) { if (lineItem.catalogReference.catalogItemId === goldRingItemId && lineItem.quantity > 5) { return true; } } return false; } function findGoldRingLineItemId(lineItems) { for (const lineItem of lineItems) { if (lineItem.catalogReference.catalogItemId === goldRingItemId) { return lineItem._id; } } return undefined; } function createViolation(severity, target, description) { return { severity, target, description }; } ``` ---