Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

built-in bank-card number valid rule #3360

Open
swift-fs opened this issue Mar 11, 2024 · 1 comment
Open

built-in bank-card number valid rule #3360

swift-fs opened this issue Mar 11, 2024 · 1 comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@swift-fs
Copy link

func Test_BankCard(t *testing.T) {
	gtest.C(t, func(t *gtest.T) {
		rule := "bank-card"
		val1 := "6230514630000424470"
		val2 := "6230514630000424473"
		// this bocom card  valid result is already true and error is nil
		val3 := "60142870670591508"
		err1 := g.Validator().Data(val1).Rules(rule).Run(ctx)
		err2 := g.Validator().Data(val2).Rules(rule).Run(ctx)
		err3 := g.Validator().Data(val3).Rules(rule).Run(ctx)
		t.AssertNE(err1, nil)
		t.Assert(err2, nil)
		// but no pass
		t.Assert(err3, nil)
	})
}

The bank card number of bocom does not fully follow the luhn algorithm and needs to be optimized and adapted.

@swift-fs swift-fs added the bug It is confirmed a bug, but don't worry, we'll handle it. label Mar 11, 2024
@swift-fs swift-fs reopened this Mar 11, 2024
@swift-fs
Copy link
Author

Currently I have customized the rules to fit older bank card numbers, and this issue can be closed directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.
Projects
None yet
Development

No branches or pull requests

1 participant