Skip to content

Commit 2804dac

Browse files
committed
API 0.1.0
1 parent 927b243 commit 2804dac

29 files changed

+63
-100
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ for JavaScript applications.
1212

1313
Step 1, install.
1414

15-
You can install IDValidators by
15+
You can install IDNumber by
1616

1717
* directly import in browser
1818

1919
```html
20-
<script src="dist/bin/IDValidators.js"></script>
20+
<script src="IDNumber.js"></script>
2121
<!-- Please edit the URL above. -->
2222
```
2323

24-
[Download latest build.](https://raw.githubusercontent.com/imdreamrunner/js-id-number/master/dist/bin/IDValidators.js)
24+
[Download latest build.](https://raw.githubusercontent.com/imdreamrunner/js-id-number/master/dist/bin/IDNumber.js)
2525

2626
* using in node.js or webpack
2727

@@ -30,20 +30,20 @@ You can install IDValidators by
3030
You can import it via require.
3131

3232
```javascript
33-
const IDValidators = require('id-number');
33+
const IDNumber = require('id-number');
3434
```
3535

3636
Or in ES6 style.
3737

3838

3939
```javascript
40-
import IDValidators from 'id-number';
40+
import IDNumber from 'id-number';
4141
```
4242

4343
Step 2, get a validator.
4444

4545
```javascript
46-
const validator = IDValidators.getValidator('SG', 'NRIC');
46+
const validator = IDNumber.getValidator('SG', 'NRIC');
4747
```
4848

4949
Step 3, validate an input.
@@ -81,7 +81,7 @@ To test: `npm test`
8181
Step 1: Write the validator in TypeScript in the directory `src/providers/<name>.ts`.
8282
The validator shall be a function returning a `InternalValidateResult`.
8383

84-
Step 2: Register the validator in `src/IDValidators.ts`
84+
Step 2: Register the validator in `src/IDNumber.ts`
8585

8686
Step 3: Write test cases at `test/<name.ts>`.
8787

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ declare module "providers/CN_ID" {
4545
validate(idNumber: string): InternalValidateResult;
4646
}
4747
}
48-
declare module "IDValidators" {
48+
declare module "IDNumber" {
4949
import { Validator } from "types";
50-
export class IDValidators {
50+
export class IDNumber {
5151
static getValidator(country: string, document: string): Validator;
5252
}
5353
}
5454
declare module "index" {
55-
import { IDValidators } from "IDValidators";
56-
export default IDValidators;
55+
import { IDNumber } from "IDNumber";
56+
export default IDNumber;
5757
}
5858
declare module "providers/sample" {
5959
import { InternalValidator, InternalValidateResult } from "types";
Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ define("types", ["require", "exports"], function (require, exports) {
88
})(exports.ErrorCode || (exports.ErrorCode = {}));
99
var ErrorCode = exports.ErrorCode;
1010
});
11-
///<reference path='../types.ts'/>
1211
define("providers/SG_NRIC", ["require", "exports", "types"], function (require, exports, types_1) {
1312
"use strict";
1413
var SingaporeNRICValidator = (function () {
@@ -66,7 +65,6 @@ define("providers/SG_NRIC", ["require", "exports", "types"], function (require,
6665
Object.defineProperty(exports, "__esModule", { value: true });
6766
exports.default = SingaporeNRICValidator;
6867
});
69-
///<reference path='../types.ts'/>
7068
define("providers/TW_ID", ["require", "exports", "types"], function (require, exports, types_2) {
7169
"use strict";
7270
var TaiwanIDValidator = (function () {
@@ -131,7 +129,6 @@ define("providers/TW_ID", ["require", "exports", "types"], function (require, ex
131129
Object.defineProperty(exports, "__esModule", { value: true });
132130
exports.default = TaiwanIDValidator;
133131
});
134-
///<reference path='../types.ts'/>
135132
define("providers/CN_ID", ["require", "exports", "types"], function (require, exports, types_3) {
136133
"use strict";
137134
var ChinaIDValidator = (function () {
@@ -239,10 +236,7 @@ define("providers/CN_ID", ["require", "exports", "types"], function (require, ex
239236
Object.defineProperty(exports, "__esModule", { value: true });
240237
exports.default = ChinaIDValidator;
241238
});
242-
///<reference path='types'/>
243-
///<reference path='providers/SG_NRIC'/>
244-
///<reference path='providers/TW_ID'/>
245-
define("IDValidators", ["require", "exports", "types", "providers/SG_NRIC", "providers/TW_ID", "providers/CN_ID"], function (require, exports, types_4, SG_NRIC_1, TW_ID_1, CN_ID_1) {
239+
define("IDNumber", ["require", "exports", "types", "providers/SG_NRIC", "providers/TW_ID", "providers/CN_ID"], function (require, exports, types_4, SG_NRIC_1, TW_ID_1, CN_ID_1) {
246240
"use strict";
247241
var providerRegistry = {
248242
'SG': {
@@ -255,10 +249,10 @@ define("IDValidators", ["require", "exports", "types", "providers/SG_NRIC", "pro
255249
'ID': CN_ID_1.default
256250
}
257251
};
258-
var IDValidators = (function () {
259-
function IDValidators() {
252+
var IDNumber = (function () {
253+
function IDNumber() {
260254
}
261-
IDValidators.getValidator = function (country, document) {
255+
IDNumber.getValidator = function (country, document) {
262256
if (providerRegistry.hasOwnProperty(country)) {
263257
var countryValidators = providerRegistry[country];
264258
if (countryValidators.hasOwnProperty(document)) {
@@ -275,20 +269,19 @@ define("IDValidators", ["require", "exports", "types", "providers/SG_NRIC", "pro
275269
}
276270
}
277271
};
278-
return IDValidators;
272+
return IDNumber;
279273
}());
280-
exports.IDValidators = IDValidators;
274+
exports.IDNumber = IDNumber;
281275
});
282-
define("index", ["require", "exports", "IDValidators"], function (require, exports, IDValidators_1) {
276+
define("index", ["require", "exports", "IDNumber"], function (require, exports, IDNumber_1) {
283277
"use strict";
284278
Object.defineProperty(exports, "__esModule", { value: true });
285-
exports.default = IDValidators_1.IDValidators;
279+
exports.default = IDNumber_1.IDNumber;
286280
// To support both require and ES6 import default.
287-
for (var attr in IDValidators_1.IDValidators) {
288-
exports[attr] = IDValidators_1.IDValidators[attr];
281+
for (var attr in IDNumber_1.IDNumber) {
282+
exports[attr] = IDNumber_1.IDNumber[attr];
289283
}
290284
});
291-
///<reference path='../types.ts'/>
292285
define("providers/sample", ["require", "exports", "types"], function (require, exports, types_5) {
293286
"use strict";
294287
var SampleValidator = (function () {
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
;(function(global) {
2-
var types = {}, providers_SG_NRIC = {}, providers_TW_ID = {}, providers_CN_ID = {}, IDValidators = {}, index = {}, providers_sample = {};
2+
var types = {}, providers_SG_NRIC = {}, providers_TW_ID = {}, providers_CN_ID = {}, IDNumber = {}, index = {}, providers_sample = {};
33
types = function (exports) {
44
(function (ErrorCode) {
55
ErrorCode[ErrorCode['error_input_variable'] = 0] = 'error_input_variable';
@@ -284,16 +284,16 @@ providers_CN_ID = function (exports, types_3) {
284284
exports.default = ChinaIDValidator;
285285
return exports;
286286
}(providers_CN_ID, types);
287-
IDValidators = function (exports, types_4, SG_NRIC_1, TW_ID_1, CN_ID_1) {
287+
IDNumber = function (exports, types_4, SG_NRIC_1, TW_ID_1, CN_ID_1) {
288288
var providerRegistry = {
289289
'SG': { 'NRIC': SG_NRIC_1.default },
290290
'TW': { 'ID': TW_ID_1.default },
291291
'CN': { 'ID': CN_ID_1.default }
292292
};
293-
var IDValidators = function () {
294-
function IDValidators() {
293+
var IDNumber = function () {
294+
function IDNumber() {
295295
}
296-
IDValidators.getValidator = function (country, document) {
296+
IDNumber.getValidator = function (country, document) {
297297
if (providerRegistry.hasOwnProperty(country)) {
298298
var countryValidators = providerRegistry[country];
299299
if (countryValidators.hasOwnProperty(document)) {
@@ -310,20 +310,20 @@ IDValidators = function (exports, types_4, SG_NRIC_1, TW_ID_1, CN_ID_1) {
310310
}
311311
}
312312
};
313-
return IDValidators;
313+
return IDNumber;
314314
}();
315-
exports.IDValidators = IDValidators;
315+
exports.IDNumber = IDNumber;
316316
return exports;
317-
}(IDValidators, types, providers_SG_NRIC, providers_TW_ID, providers_CN_ID);
318-
index = function (exports, IDValidators_1) {
317+
}(IDNumber, types, providers_SG_NRIC, providers_TW_ID, providers_CN_ID);
318+
index = function (exports, IDNumber_1) {
319319
Object.defineProperty(exports, '__esModule', { value: true });
320-
exports.default = IDValidators_1.IDValidators;
320+
exports.default = IDNumber_1.IDNumber;
321321
// To support both require and ES6 import default.
322-
for (var attr in IDValidators_1.IDValidators) {
323-
exports[attr] = IDValidators_1.IDValidators[attr];
322+
for (var attr in IDNumber_1.IDNumber) {
323+
exports[attr] = IDNumber_1.IDNumber[attr];
324324
}
325325
return exports;
326-
}(index, IDValidators);
326+
}(index, IDNumber);
327327
providers_sample = function (exports, types_5) {
328328
var SampleValidator = function () {
329329
function SampleValidator() {
@@ -340,4 +340,4 @@ providers_sample = function (exports, types_5) {
340340
exports.default = SampleValidator;
341341
return exports;
342342
}(providers_sample, types);
343-
global.IDValidators=index.default;}(window));
343+
global.IDNumber=index.default;}(window));
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { Validator } from "./types";
2-
export declare class IDValidators {
2+
export declare class IDNumber {
33
static getValidator(country: string, document: string): Validator;
44
}
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
///<reference path='types'/>
2-
///<reference path='providers/SG_NRIC'/>
3-
///<reference path='providers/TW_ID'/>
41
"use strict";
52
var types_1 = require("./types");
63
var SG_NRIC_1 = require("./providers/SG_NRIC");
@@ -17,10 +14,10 @@ var providerRegistry = {
1714
'ID': CN_ID_1.default
1815
}
1916
};
20-
var IDValidators = (function () {
21-
function IDValidators() {
17+
var IDNumber = (function () {
18+
function IDNumber() {
2219
}
23-
IDValidators.getValidator = function (country, document) {
20+
IDNumber.getValidator = function (country, document) {
2421
if (providerRegistry.hasOwnProperty(country)) {
2522
var countryValidators = providerRegistry[country];
2623
if (countryValidators.hasOwnProperty(document)) {
@@ -37,6 +34,6 @@ var IDValidators = (function () {
3734
}
3835
}
3936
};
40-
return IDValidators;
37+
return IDNumber;
4138
}());
42-
exports.IDValidators = IDValidators;
39+
exports.IDNumber = IDNumber;

dist/commonjs/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import { IDValidators } from "./IDValidators";
2-
export default IDValidators;
1+
import { IDNumber } from "./IDNumber";
2+
export default IDNumber;

dist/commonjs/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"use strict";
2-
var IDValidators_1 = require("./IDValidators");
2+
var IDNumber_1 = require("./IDNumber");
33
Object.defineProperty(exports, "__esModule", { value: true });
4-
exports.default = IDValidators_1.IDValidators;
4+
exports.default = IDNumber_1.IDNumber;
55
// To support both require and ES6 import default.
6-
for (var attr in IDValidators_1.IDValidators) {
7-
exports[attr] = IDValidators_1.IDValidators[attr];
6+
for (var attr in IDNumber_1.IDNumber) {
7+
exports[attr] = IDNumber_1.IDNumber[attr];
88
}

dist/commonjs/providers/CN_ID.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/// <reference path="../types.d.ts" />
21
import { InternalValidator, InternalValidateResult } from "../types";
32
export default class ChinaIDValidator implements InternalValidator {
43
validate(idNumber: string): InternalValidateResult;

dist/commonjs/providers/CN_ID.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
///<reference path='../types.ts'/>
21
"use strict";
32
var types_1 = require("../types");
43
var ChinaIDValidator = (function () {

0 commit comments

Comments
 (0)