UNPKG

715 BJavaScriptView Raw
1/*!
2 * Copyright (c) 2012-2018 Digital Bazaar, Inc. All rights reserved.
3 */
4const bedrock = require('bedrock');
5
6const schema = {
7 title: 'Slug',
8 description: 'A short identifier within a URL.',
9 type: 'string',
10 pattern: '^[a-z0-9][-a-z0-9~_\\.]*$',
11 minLength: 3,
12 maxLength: 40,
13 errors: {
14 invalid:
15 'The slug must start with a letter or number, contain only lowercase ' +
16 'letters, numbers, hyphens, periods, underscores, and tildes. It must ' +
17 'between 3 and 40 characters in length.',
18 missing: 'Please enter a slug.'
19 }
20};
21
22module.exports = function(extend) {
23 if(extend) {
24 return bedrock.util.extend(true, bedrock.util.clone(schema), extend);
25 }
26 return schema;
27};