Allow C12 cards for fervidex integrations

This commit is contained in:
zkldi
2021-12-03 09:15:49 +00:00
parent 0d9d0e745f
commit e4fe94c3b5
@@ -136,8 +136,11 @@ function FervidexForm({
});
}}
/>
{formSettings.cards.some(x => x !== "" && x.length !== 16) && (
<div className="text-danger">CardIDs should be 16 characters!</div>
{formSettings.cards.some(c => !isCardIDValid(c)) && (
<div className="text-danger">
CardIDs should be 16 characters, or a <code>C</code> followed by 12
characters!
</div>
)}
{formSettings.cards.some(x => x.startsWith("E004")) && (
<div className="text-danger">
@@ -166,3 +169,15 @@ function FervidexForm({
</form>
);
}
function isCardIDValid(cardID: string) {
if (cardID.startsWith("E004")) {
return false;
}
if (cardID[0] === "C") {
return cardID.length === 13;
}
return cardID.length === 16;
}