@bedrockio/model 0.1.21 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/schema.js +10 -0
- package/package.json +1 -1
- package/src/schema.js +8 -0
package/dist/cjs/schema.js
CHANGED
|
@@ -180,6 +180,7 @@ function applyExtensions(typedef) {
|
|
|
180
180
|
applySyntaxExtensions(typedef);
|
|
181
181
|
applyUniqueExtension(typedef);
|
|
182
182
|
applyTupleExtension(typedef);
|
|
183
|
+
applyDateExtension(typedef);
|
|
183
184
|
}
|
|
184
185
|
function applySyntaxExtensions(typedef) {
|
|
185
186
|
const {
|
|
@@ -242,6 +243,15 @@ function applyTupleExtension(typedef) {
|
|
|
242
243
|
typedef.validate = (0, _validation.getTupleValidator)(type);
|
|
243
244
|
}
|
|
244
245
|
}
|
|
246
|
+
function applyDateExtension(typedef) {
|
|
247
|
+
const {
|
|
248
|
+
type,
|
|
249
|
+
default: defaultValue
|
|
250
|
+
} = typedef;
|
|
251
|
+
if (type === 'Date' && defaultValue === 'now') {
|
|
252
|
+
typedef.default = Date.now;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
245
255
|
|
|
246
256
|
// Intercepts "unique" options and changes to "softUnique".
|
|
247
257
|
function applyUniqueExtension(typedef) {
|
package/package.json
CHANGED
package/src/schema.js
CHANGED
|
@@ -195,6 +195,7 @@ function applyExtensions(typedef) {
|
|
|
195
195
|
applySyntaxExtensions(typedef);
|
|
196
196
|
applyUniqueExtension(typedef);
|
|
197
197
|
applyTupleExtension(typedef);
|
|
198
|
+
applyDateExtension(typedef);
|
|
198
199
|
}
|
|
199
200
|
|
|
200
201
|
function applySyntaxExtensions(typedef) {
|
|
@@ -250,6 +251,13 @@ function applyTupleExtension(typedef) {
|
|
|
250
251
|
}
|
|
251
252
|
}
|
|
252
253
|
|
|
254
|
+
function applyDateExtension(typedef) {
|
|
255
|
+
const { type, default: defaultValue } = typedef;
|
|
256
|
+
if (type === 'Date' && defaultValue === 'now') {
|
|
257
|
+
typedef.default = Date.now;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
253
261
|
// Intercepts "unique" options and changes to "softUnique".
|
|
254
262
|
function applyUniqueExtension(typedef) {
|
|
255
263
|
if (typedef.unique === true) {
|