How to use the simpl-schema.ErrorTypes function in simpl-schema

To help you get started, we’ve selected a few simpl-schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github naustudio / node-vn-payments / src / onepay.js View on Github external
custom() {
			let shouldBeRequired = false;
			const gateway = this.field('paymentGateway').value;
			if (gateway.includes('vpcpay')) {
				// International gateway requires againLink
				shouldBeRequired = true;
			}

			if (shouldBeRequired && (this.value == null || this.value === '')) {
				return SimpleSchema.ErrorTypes.REQUIRED;
			}

			// field is valid
			return undefined;
		},
	},
github Blockrazor / blockrazor / imports / api / coins / currencies.js View on Github external
custom() {
      // SimpleSchema.ErrorTypes.VALUE_NOT_ALLOWED
      //returns null if not applicable, undefined if applicable and passing, err otherwise
      var res = Currencies.schemaFuncs.ifAltCoinExisting.call(this)
      //condition for AltCoinExisting
      if (res !== null){
        res = this.value < 1231006505000? SimpleSchema.ErrorTypes.MIN_NUMBER : null
      } else {
        res = Currencies.schemaFuncs.ifAltCoinWTV.call(this)
        if (res !== null){
          res = this.value < 1509032068000? SimpleSchema.ErrorTypes.MIN_NUMBER : null
        }
      }
      return res
    },
  },
github reactioncommerce / reaction / client / modules / i18n / main.js View on Github external
export function getValidationErrorMessages() {
  const messages = {};
  values(SimpleSchema.ErrorTypes).forEach((errorType) => {
    const i18nKey = `globalMessages.${errorType}`;
    const message = i18next.t(i18nKey);
    if (new RegExp("string").test(message) !== true && message !== i18nKey) {
      messages[errorType] = message;
    }
  });
  return messages;
}
github Blockrazor / blockrazor / imports / api / coins / currencies.js View on Github external
function nullValidator() {
  if (this.value === null || this.value === "") return SimpleSchema.ErrorTypes.REQUIRED
}
github ejfrancis / Meteor-Vue-Enterprise-Starter / src / imports / modules / accounts / shared / schemas / password-schema.js View on Github external
Array.from(this.value).forEach((letter) => {
        if (uppercase.indexOf(letter) !== -1) {
          numUppercase++;
        }
        if (lowercase.indexOf(letter) !== -1) {
          numLowercase++;
        }
        if (specialCharacters.indexOf(letter) !== -1) {
          numSpecialCharacters++;
        }
      });

      if (numUppercase < requiredUppsercase ||
        numLowercase < requiredLowercase ||
        numSpecialCharacters < requiredSpecialCharacters) {
        return SimpleSchema.ErrorTypes.VALUE_NOT_ALLOWED;
      }
      return undefined;
    }
  }
github reactioncommerce / reaction / imports / node-app / core-services / payments / mutations / enablePaymentMethodForShop.js View on Github external
export default async function enablePaymentMethodForShop(context, input = {}) {
  paramsSchema.validate(input, { ignore: [SimpleSchema.ErrorTypes.KEY_NOT_IN_SCHEMA] });
  const { Shops } = context.collections;
  const { isEnabled, paymentMethodName, shopId } = input;

  if (!context.userHasPermission(["owner", "admin"], shopId)) {
    throw new ReactionError("access-denied", "Access denied");
  }

  if (!allPaymentMethods[paymentMethodName]) {
    throw new ReactionError("not-found", "Requested payment method is invalid");
  }

  const shop = await context.queries.shopById(context, shopId);
  if (!shop) throw new ReactionError("not-found", "Shop not found");

  const methods = new Set(shop.availablePaymentMethods);
github reactioncommerce / reaction / src / core-services / payments / mutations / enablePaymentMethodForShop.js View on Github external
export default async function enablePaymentMethodForShop(context, input = {}) {
  paramsSchema.validate(input, { ignore: [SimpleSchema.ErrorTypes.KEY_NOT_IN_SCHEMA] });
  const { checkPermissions, collections } = context;
  const { Shops } = collections;
  const { isEnabled, paymentMethodName, shopId } = input;

  await checkPermissions(["owner", "admin"], shopId);

  if (!allPaymentMethods[paymentMethodName]) {
    throw new ReactionError("not-found", "Requested payment method is invalid");
  }

  const shop = await context.queries.shopById(context, shopId);
  if (!shop) throw new ReactionError("not-found", "Shop not found");

  const methods = new Set(shop.availablePaymentMethods);

  if (isEnabled) {
github reactioncommerce / reaction / imports / collections / schemas / products.js View on Github external
custom() {
      if (Meteor.isClient) {
        if (!(this.siblingField("type").value === "inventory" || this.value ||
          this.value === 0)) {
          return SimpleSchema.ErrorTypes.REQUIRED;
        }
      }
    }
  },