Skip to content

Commit 1ddb8a9

Browse files
committed
v1.1.3
1 parent 61e123e commit 1ddb8a9

File tree

8 files changed

+66
-43
lines changed

8 files changed

+66
-43
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphql-scalars",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "A collection of scalar types not included in base GraphQL.",
55
"repository": {
66
"type": "git",

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export {
3636
JSONObject as JSONObjectDefinition,
3737
IBAN as IBANTypeDefinition,
3838
ObjectID as ObjectIDTypeDefinition,
39+
Void as VoidTypeDefinition,
3940
} from './typeDefs';
4041

4142
export { default as typeDefs } from './typeDefs';
@@ -75,6 +76,7 @@ export {
7576
JSONObject as JSONObjectResolver,
7677
IBAN as IBANResolver,
7778
ObjectID as ObjectIDResolver,
79+
Void as VoidResolver,
7880
} from './resolvers';
7981

8082
export {
@@ -112,6 +114,7 @@ export {
112114
JSONObject as GraphQLJSONObject,
113115
IBAN as GraphQLIBAN,
114116
ObjectID as GraphQLObjectID,
117+
Void as GraphQLVoid,
115118
} from './resolvers';
116119

117120
export { resolvers };
@@ -151,6 +154,7 @@ export {
151154
JSONObject as JSONObjectMock,
152155
IBAN as IBANMock,
153156
ObjectID as ObjectIDMock,
157+
Void as VoidMock,
154158
} from './mocks';
155159

156160
export { mocks };

src/mocks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export const USCurrency = () => 1000;
7777
export const JSON = () => ({});
7878
export const JSONObject = () => ({});
7979
export const IBAN = () => 'NL55INGB4789170233';
80+
export const Void = (): null => null;
8081

8182
export {
8283
URLMock as URL,

src/resolvers/IBAN.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,6 @@ const IBAN_SPECIFICATIONS: CountryStructure = {
288288
XK: { length: 20, structure: 'F04F10F02', example: 'XK051212012345678906' },
289289
};
290290

291-
const NON_ALPHANUM = /[^a-zA-Z0-9]/g;
292-
293291
const A = 'A'.charCodeAt(0);
294292
const Z = 'Z'.charCodeAt(0);
295293

@@ -386,16 +384,12 @@ function _testIBAN(
386384
}
387385

388386
function validate(iban: string): boolean {
389-
iban = electronicFormat(iban);
387+
iban = iban.toUpperCase();
390388
const countryCode = iban.slice(0, 2);
391389
const countryStructure = IBAN_SPECIFICATIONS[countryCode];
392390
return !!countryStructure && _testIBAN(iban, countryCode, countryStructure);
393391
}
394392

395-
function electronicFormat(iban: string): string {
396-
return iban.replace(NON_ALPHANUM, '').toUpperCase();
397-
}
398-
399393
export default new GraphQLScalarType({
400394
name: `IBAN`,
401395
description: `A field whose value is an International Bank Account Number (IBAN): https://en.wikipedia.org/wiki/International_Bank_Account_Number.`,

src/resolvers/Void.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { GraphQLScalarType } from 'graphql';
2+
3+
export default new GraphQLScalarType({
4+
name: 'Void',
5+
6+
description: 'Represents NULL values',
7+
8+
serialize() {
9+
return null;
10+
},
11+
12+
parseValue() {
13+
return null;
14+
},
15+
16+
parseLiteral() {
17+
return null;
18+
},
19+
});

src/resolvers/index.ts

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import USCurrency from './USCurrency';
2828
import { JSON, JSONObject } from './JSON';
2929
import IBAN from './IBAN';
3030
import ObjectID from './ObjectID';
31+
import Void from './Void';
3132

3233
const BigIntResolver = BigIntFactory('BigInt');
3334
const LongResolver = BigIntFactory('Long');
@@ -39,38 +40,39 @@ const NonNegativeFloatResolver = NonNegativeFloatFactory('NonNegativeFloat');
3940
const UnsignedFloatResolver = NonNegativeFloatFactory('UnsignedFloat');
4041

4142
export {
42-
DateTime,
43-
NonPositiveInt,
44-
PositiveInt,
45-
NonNegativeIntResolver as NonNegativeInt,
46-
UnsignedIntResolver as UnsignedInt,
47-
NegativeInt,
48-
NonPositiveFloat,
49-
PositiveFloat,
50-
NonNegativeFloatResolver as NonNegativeFloat,
51-
UnsignedFloatResolver as UnsignedFloat,
52-
NegativeFloat,
53-
EmailAddress,
54-
URL,
55-
PhoneNumber,
56-
PostalCode,
57-
BigIntResolver as BigInt,
58-
LongResolver as Long,
59-
GUID,
60-
Hexadecimal,
61-
HexColorCode,
62-
HSL,
63-
HSLA,
64-
IPv4,
65-
IPv6,
66-
ISBN,
67-
MAC,
68-
Port,
69-
RGB,
70-
RGBA,
71-
USCurrency,
72-
JSON,
73-
JSONObject,
74-
IBAN,
75-
ObjectID,
43+
DateTime,
44+
NonPositiveInt,
45+
PositiveInt,
46+
NonNegativeIntResolver as NonNegativeInt,
47+
UnsignedIntResolver as UnsignedInt,
48+
NegativeInt,
49+
NonPositiveFloat,
50+
PositiveFloat,
51+
NonNegativeFloatResolver as NonNegativeFloat,
52+
UnsignedFloatResolver as UnsignedFloat,
53+
NegativeFloat,
54+
EmailAddress,
55+
URL,
56+
PhoneNumber,
57+
PostalCode,
58+
BigIntResolver as BigInt,
59+
LongResolver as Long,
60+
GUID,
61+
Hexadecimal,
62+
HexColorCode,
63+
HSL,
64+
HSLA,
65+
IPv4,
66+
IPv6,
67+
ISBN,
68+
MAC,
69+
Port,
70+
RGB,
71+
RGBA,
72+
USCurrency,
73+
JSON,
74+
JSONObject,
75+
IBAN,
76+
ObjectID,
77+
Void,
7678
};

src/typeDefs.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export const UnsignedInt = 'scalar UnsignedInt';
3434
export const Long = 'scalar Long';
3535
export const ObjectID = 'scalar ObjectID';
3636

37+
export const Void = 'scalar Void';
38+
3739
export default [
3840
DateTime,
3941
EmailAddress,
@@ -69,4 +71,5 @@ export default [
6971
JSONObject,
7072
IBAN,
7173
ObjectID,
74+
Void,
7275
];

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"noUnusedParameters": true,
2121
"resolveJsonModule": true,
2222
"importHelpers": true,
23-
"typeRoots": [ "./types", "./node_modules/@types"],
23+
"typeRoots": ["./types", "./node_modules/@types"],
2424
"baseUrl": ".",
2525
"paths": {
2626
"*": ["./types/*"]

0 commit comments

Comments
 (0)