npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pinelab/vendure-plugin-validate-cart

v1.1.0

Published

Vendure plugin for validating the cart before checkout

Readme

Vendure Validate Cart Plugin

Official documentation here

A very lightweight plugin to have custom cart validation rules before proceeding to checkout. For example to check current stock, or check for limited products. You can implement your own validation rules by implementing the CartValidatorStrategy interface.

Getting started

Add the plugin to your config:

import {
  ValidateCartPlugin,
  DefaultStockValidationStrategy,
} from '@pinelab/vendure-plugin-validate-cart';

// In your plugins array, in vendure-config.ts
plugins: [
  ValidateCartPlugin.init({
    // This is just the sample strategy that checks if the cart has enough stock for the items in the cart.
    validationStrategy: new DefaultStockValidationStrategy(),
  }),
];

This will add a validateActiveOrder mutation to the shop API.

Storefront usage

Depending on your validation strategy, you probably want to call the validateActiveOrder mutation in the cart page, and again on the payment page:

mutation ValidateActiveOrderMutation {
  validateActiveOrder {
    message
    errorCode
    relatedOrderLineIds
  }
}

If any validation errors are returned, you can display the error to the user with the corresponding order lines. You could even automatically remove the items from the cart based on the relatedOrderLineIds.

This action is a mutation rather than a query, because your custom validation logic might need to modify the order, for example to 'lock' an order after validation until payment is completed.

Custom validation rules

You can implement your own validation rules by implementing the CartValidatorStrategy interface. For example, to check if active promotions are still valid for the items in the cart.

import {
  ValidateCartStrategy,
  ActiveOrderValidationError,
} from '@pinelab/vendure-plugin-validate-cart';

export class PromotionValidator implements ValidateCartStrategy {
  // Tell the plugin to pre-load the promotions for the order
  loadOrderRelations: RelationPaths<Order> = ['promotions'];

  // Validate the order based on your custom logic
  async validate(ctx: RequestContext, activeOrder: Order, injector: Injector) {
    const errors: ActiveOrderValidationError[] = [];
    for (const promotion of activeOrder.promotions) {
      if (!isPromotionValid(promotion)) {
        errors.push({
          message: `Promotion ${promotion.name} is not valid`,
          errorCode: `INVALID_PROMOTION`,
        });
      }
    }
    return errors;
  }
}