Open timarney opened 5 years ago
Use this for your schema.js file
const isCreditCard = require("validator/lib/isCreditCard").default;
const Schema = {
card_type: {
isIn: {
errorMessage: "errors.card_type.valid",
options: [["Visa", "MasterCard"]]
}
},
card_number: {
custom: {
options: (value, { req }) => {
return isCreditCard(value);
},
errorMessage: "errors.card_number.valid"
}
},
ccv: {
isLength: {
errorMessage: "errors.ccv.length",
options: { min: 3, max: 3 }
}
},
expiry: {
isLength: {
errorMessage: "errors.expiry.length",
options: { min: 5, max: 5 }
}
}
};
module.exports = {
Schema
};
In the view file for the Credit Card radio buttons use the pug mixin
extends /base
include /_includes/radios
//... more code
+radioButtons('card_type', {1:'Visa',2:'MasterCard'}, data.card_type, 'Name of card', errors)
Test card #'s MasterCard => 5555555555554444 MasterCard =>5105105105105100 Visa => 4111111111111111
Collect fake Credit card data (Radio Visa/MC number, exp date, CCV)