Skip to content

Commit 6d9f9cf

Browse files
committed
prop: make (de)serialization the same
Previously, deserializing and then reserializing a config prop list would give different results due to allowNull() and unique() not taking and argument. Semver: minor
1 parent 813ceb3 commit 6d9f9cf

File tree

4 files changed

+85
-31
lines changed

4 files changed

+85
-31
lines changed

README.md

Lines changed: 77 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ Returns `this`
5656

5757
Returns `this`
5858

59-
##### unique()
59+
##### unique(val)
60+
61+
* `val` [`<Boolean>`][] Is this property unique?
6062

6163
Returns `this`
6264

@@ -78,9 +80,9 @@ Returns `this`
7880

7981
Returns `this`
8082

81-
##### allowNull()
83+
##### allowNull(val)
8284

83-
Allow the property to be null
85+
* `val` [`<Boolean>`][] Allow the property to be null?
8486

8587
Returns `this`
8688

@@ -121,7 +123,9 @@ Returns `this`
121123

122124
Returns `this`
123125

124-
##### unique()
126+
##### unique(val)
127+
128+
* `val` [`<Boolean>`][] Is this property unique?
125129

126130
Returns `this`
127131

@@ -143,7 +147,9 @@ Returns `this`
143147

144148
Returns `this`
145149

146-
##### allowNull()
150+
##### allowNull(val)
151+
152+
* `val` [`<Boolean>`][] Allow the property to be null?
147153

148154
Allow the property to be null
149155

@@ -186,7 +192,9 @@ Returns `this`
186192

187193
Returns `this`
188194

189-
##### unique()
195+
##### unique(val)
196+
197+
* `val` [`<Boolean>`][] Is this property unique?
190198

191199
Returns `this`
192200

@@ -208,7 +216,9 @@ Returns `this`
208216

209217
Returns `this`
210218

211-
##### allowNull()
219+
##### allowNull(val)
220+
221+
* `val` [`<Boolean>`][] Allow the property to be null?
212222

213223
Allow the property to be null
214224

@@ -251,7 +261,9 @@ Returns `this`
251261

252262
Returns `this`
253263

254-
##### unique()
264+
##### unique(val)
265+
266+
* `val` [`<Boolean>`][] Is this property unique?
255267

256268
Returns `this`
257269

@@ -273,7 +285,9 @@ Returns `this`
273285

274286
Returns `this`
275287

276-
##### allowNull()
288+
##### allowNull(val)
289+
290+
* `val` [`<Boolean>`][] Allow the property to be null?
277291

278292
Allow the property to be null
279293

@@ -334,7 +348,9 @@ Returns `this`
334348

335349
Returns `this`
336350

337-
##### unique()
351+
##### unique(val)
352+
353+
* `val` [`<Boolean>`][] Is this property unique?
338354

339355
Returns `this`
340356

@@ -356,7 +372,9 @@ Returns `this`
356372

357373
Returns `this`
358374

359-
##### allowNull()
375+
##### allowNull(val)
376+
377+
* `val` [`<Boolean>`][] Allow the property to be null?
360378

361379
Allow the property to be null
362380

@@ -399,7 +417,9 @@ Returns `this`
399417

400418
Returns `this`
401419

402-
##### unique()
420+
##### unique(val)
421+
422+
* `val` [`<Boolean>`][] Is this property unique?
403423

404424
Returns `this`
405425

@@ -421,7 +441,9 @@ Returns `this`
421441

422442
Returns `this`
423443

424-
##### allowNull()
444+
##### allowNull(val)
445+
446+
* `val` [`<Boolean>`][] Allow the property to be null?
425447

426448
Allow the property to be null
427449

@@ -484,7 +506,9 @@ Returns `this`
484506

485507
Returns `this`
486508

487-
##### unique()
509+
##### unique(val)
510+
511+
* `val` [`<Boolean>`][] Is this property unique?
488512

489513
Returns `this`
490514

@@ -506,7 +530,9 @@ Returns `this`
506530

507531
Returns `this`
508532

509-
##### allowNull()
533+
##### allowNull(val)
534+
535+
* `val` [`<Boolean>`][] Allow the property to be null?
510536

511537
Allow the property to be null
512538

@@ -571,7 +597,9 @@ Returns `this`
571597

572598
Returns `this`
573599

574-
##### unique()
600+
##### unique(val)
601+
602+
* `val` [`<Boolean>`][] Is this property unique?
575603

576604
Returns `this`
577605

@@ -587,7 +615,9 @@ Returns `this`
587615

588616
Returns `this`
589617

590-
##### allowNull()
618+
##### allowNull(val)
619+
620+
* `val` [`<Boolean>`][] Allow the property to be null?
591621

592622
Allow the property to be null
593623

@@ -643,7 +673,9 @@ Returns `this`
643673

644674
Returns `this`
645675

646-
##### unique()
676+
##### unique(val)
677+
678+
* `val` [`<Boolean>`][] Is this property unique?
647679

648680
Returns `this`
649681

@@ -659,7 +691,9 @@ Returns `this`
659691

660692
Returns `this`
661693

662-
##### allowNull()
694+
##### allowNull(val)
695+
696+
* `val` [`<Boolean>`][] Allow the property to be null?
663697

664698
Allow the property to be null
665699

@@ -714,7 +748,9 @@ Returns `this`
714748

715749
Returns `this`
716750

717-
##### unique()
751+
##### unique(val)
752+
753+
* `val` [`<Boolean>`][] Is this property unique?
718754

719755
Returns `this`
720756

@@ -736,7 +772,9 @@ Returns `this`
736772

737773
Returns `this`
738774

739-
##### allowNull()
775+
##### allowNull(val)
776+
777+
* `val` [`<Boolean>`][] Allow the property to be null?
740778

741779
Allow the property to be null
742780

@@ -793,7 +831,9 @@ Returns `this`
793831

794832
Returns `this`
795833

796-
##### unique()
834+
##### unique(val)
835+
836+
* `val` [`<Boolean>`][] Is this property unique?
797837

798838
Returns `this`
799839

@@ -815,7 +855,9 @@ Returns `this`
815855

816856
Returns `this`
817857

818-
##### allowNull()
858+
##### allowNull(val)
859+
860+
* `val` [`<Boolean>`][] Allow the property to be null?
819861

820862
Allow the property to be null
821863

@@ -858,7 +900,9 @@ Returns `this`
858900

859901
Returns `this`
860902

861-
##### unique()
903+
##### unique(val)
904+
905+
* `val` [`<Boolean>`][] Is this property unique?
862906

863907
Returns `this`
864908

@@ -880,7 +924,9 @@ Returns `this`
880924

881925
Returns `this`
882926

883-
##### allowNull()
927+
##### allowNull(val)
928+
929+
* `val` [`<Boolean>`][] Allow the property to be null?
884930

885931
Allow the property to be null
886932

@@ -923,7 +969,9 @@ Returns `this`
923969

924970
Returns `this`
925971

926-
##### unique()
972+
##### unique(val)
973+
974+
* `val` [`<Boolean>`][] Is this property unique?
927975

928976
Returns `this`
929977

@@ -945,7 +993,9 @@ Returns `this`
945993

946994
Returns `this`
947995

948-
##### allowNull()
996+
##### allowNull(val)
997+
998+
* `val` [`<Boolean>`][] Allow the property to be null?
949999

9501000
Allow the property to be null
9511001

lib/prop/base.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ module.exports = class Base {
4949
return this
5050
}
5151

52-
allowNull() {
53-
this._allowNull = true
52+
allowNull(val = true) {
53+
this._allowNull = !!val
5454
return this
5555
}
5656

57-
unique() {
58-
this._unique = true
57+
unique(val = true) {
58+
this._unique = !!val
5959
return this
6060
}
6161

test/prop/fixture-out.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
, "required": true
44
, "description": "The organization's ID"
55
, "example": "8995E072-46B6-4264-A9BD-DAA955CBC360"
6+
, "allowNull": true
7+
, "unique": true
68
, "type": "uuid"
79
}
810
, { "path": "name"

test/prop/fixture.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
, "path": "id"
44
, "example": "8995E072-46B6-4264-A9BD-DAA955CBC360"
55
, "required": true
6+
, "allowNull": true
7+
, "unique": true
68
, "description": "The organization's ID"
79
}
810
, { "type": "string"

0 commit comments

Comments
 (0)