Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
},
},
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
},
},
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;
}
function nullValidator() {
if (this.value === null || this.value === "") return SimpleSchema.ErrorTypes.REQUIRED
}
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;
}
}
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);
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) {
custom() {
if (Meteor.isClient) {
if (!(this.siblingField("type").value === "inventory" || this.value ||
this.value === 0)) {
return SimpleSchema.ErrorTypes.REQUIRED;
}
}
}
},