Skip to content
This repository was archived by the owner on Oct 20, 2021. It is now read-only.

Commit 980980f

Browse files
feat(half): Option to additional char
1 parent 70cd580 commit 980980f

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

src/rules/full-width.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { AbstractRegex } from './abstract-regex';
1+
import { AbstractRegexFilter } from './abstract-regex-filter';
22

3-
export class FullWidth extends AbstractRegex {
3+
export class FullWidth extends AbstractRegexFilter {
44

55
/**
66
* Get pattern.

src/rules/half-width.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { AbstractRegex } from './abstract-regex';
1+
import { AbstractRegexFilter } from './abstract-regex-filter';
22

3-
export class HalfWidth extends AbstractRegex {
3+
export class HalfWidth extends AbstractRegexFilter {
44

55
/**
66
* Get pattern.

test/rules/full-width.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ describe('FullWidth', () => {
1515
assert.instanceOf(fullWidth, AbstractRule);
1616
});
1717

18+
it('values is valid with additional characters', () => {
19+
assert.isTrue(new FullWidth('!@#$%^&*(){}').validate('!@#$%^&*(){} test@example.com'));
20+
assert.isTrue(new FullWidth('[]?+=/\\-_|"\',<>.').validate('[]?+=/\\-_|"\',<>. \t \n test@example.com'));
21+
assert.isTrue(new FullWidth(undefined).validate('ひらがな'));
22+
});
23+
1824
it('values is valid', () => {
1925
assert.isTrue(fullWidth.validate('ひらがな・カタカナ、.漢字'));
2026
assert.isTrue(fullWidth.validate('3ー0 a@com'));

test/rules/half-width.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ describe('HalfWidth', () => {
1515
assert.instanceOf(halfWidth, AbstractRule);
1616
});
1717

18+
it('values is valid with additional characters', () => {
19+
assert.isTrue(new HalfWidth('!@#$%^&*(){}').validate('!@#$%^&*(){} abc'));
20+
assert.isTrue(new HalfWidth('[]?+=/\\-_|"\',<>.').validate('[]?+=/\\-_|"\',<>. \t \n abc'));
21+
assert.isTrue(new HalfWidth(undefined).validate('カタカナ゙ᆲ←'));
22+
});
23+
1824
it('values is valid', () => {
1925
assert.isTrue(halfWidth.validate('!"#$%&()<>/+=-_? ~^|.,@`{}[]'));
2026
assert.isTrue(halfWidth.validate('l-btn_02--active'));

0 commit comments

Comments
 (0)