We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents b32a28d + e523b9b commit bc48acdCopy full SHA for bc48acd
index.js
@@ -10,6 +10,13 @@ function validate (rut) {
10
if (typeof rut !== 'string') {
11
return false
12
}
13
+
14
+ // if it starts with 0 we return false
15
+ // so a rut like 00000000-0 will not pass
16
+ if (/^0+/.test(rut)) {
17
+ return false;
18
+ }
19
20
if (!/^0*(\d{1,3}(\.?\d{3})*)-?([\dkK])$/.test(rut)) {
21
22
test.js
@@ -36,3 +36,10 @@ test('format', t => {
36
t.is(format('18*972*631*7'), '18.972.631-7')
37
t.is(format('9068826-k'), '9.068.826-K')
38
})
39
40
+test('does not validate rut with 0 on most right digit', t => {
41
+ t.false(validate('00.000.000-0'))
42
+ t.false(validate('00000000-0'))
43
+ t.false(validate('0000000000000000000000-0'))
44
+})
45
0 commit comments