UNPKG

733 BJavaScriptView Raw
1/*!
2 * Copyright (c) 2012-2018 Digital Bazaar, Inc. All rights reserved.
3 */
4const bedrock = require('bedrock');
5
6const schema = {
7 title: 'W3C Date/Time',
8 description: 'A W3C-formatted date and time combination.',
9 type: 'string',
10 pattern: '^[1-9][0-9]{3}-(0[1-9]|1[0-2])-([0-2][0-9]|3[0-1])T([0-1][0-9]|2[0-3]):([0-5][0-9]):(([0-5][0-9])|60)(\\.[0-9]+)?(Z|((\\+|-)([0-1][0-9]|2[0-3]):([0-5][0-9])))?$',
11 errors: {
12 invalid: 'The date/time must be of the W3C date/time format "YYYY-MM-DD( |T)HH:MM:SS.s(Z|(+|-)TZOFFSET)".',
13 missing: 'Please enter a date/time.'
14 }
15};
16
17module.exports = function(extend) {
18 if(extend) {
19 return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
20 }
21 return schema;
22};