Giter VIP home page Giter VIP logo

Comments (1)

4k1k0 avatar 4k1k0 commented on July 18, 2024
func isMaestro(c *Card, ccDigits digits) bool {
	return matchesValue(ccDigits.At(4), []int{5018, 5020, 5038, 5612, 5893, 6304, 6759, 6761, 6762, 6763, 6390}) ||
		c.Number[:3] == "0604"
}

This example uses the card validator library from npm. And as we can see the card number 6799998900000200010 gets maestro as the card brand.

'use strict'
const valid = require("card-validator")

const numberValidation = valid.number("6799998900000200010")

if (!numberValidation.isPotentiallyValid) {
  console.error("error")
}

if (numberValidation.card) {
  console.log(numberValidation.card.type) // 'maestro'
}

card-validator uses credit-card-type to validate the card brands. And as we can see in src/lib/card-types.ts line 104

  maestro: {
    niceType: "Maestro",
    type: "maestro",
    patterns: [
      493698,
      [500000, 504174],
      [504176, 506698],
      [506779, 508999],
      [56, 59],
      63,
      67,
      6,
    ],
    gaps: [4, 8, 12],
    lengths: [12, 13, 14, 15, 16, 17, 18, 19],
    code: {
      name: "CVC",
      size: 3,
    },
  } as BuiltInCreditCardType,

Maestro uses more numbers as a pattern to check the brand.

    patterns: [
      493698,
      [500000, 504174],
      [504176, 506698],
      [506779, 508999],
      [56, 59],
      63,
      67,
      6,
    ],

When in Go we only use these

5018, 5020, 5038, 5612, 5893, 6304, 6759, 6761, 6762, 6763, 6390 and 0604

from go-credit-card.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.