@naturalcycles/nodejs-lib
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -0,1 +1,8 @@ | ||
# [2.1.0](https://github.com/NaturalCycles/nodejs-lib/compare/v2.0.0...v2.1.0) (2019-02-02) | ||
### Features | ||
* slugSchema, slug pattern ([f897db6](https://github.com/NaturalCycles/nodejs-lib/commit/f897db6)) | ||
# [2.0.0](https://github.com/NaturalCycles/nodejs-lib/compare/v1.0.1...v2.0.0) (2019-02-02) | ||
@@ -2,0 +9,0 @@ |
@@ -13,2 +13,10 @@ import { SchemaMap } from 'joi'; | ||
export declare const idSchema: import("./joi.extensions").ExtendedStringSchema; | ||
/** | ||
* `_` should NOT be allowed to be able to use slug-ids as part of natural ids with `_` separator. | ||
*/ | ||
export declare const SLUG_PATTERN: RegExp; | ||
/** | ||
* "Slug" - a valid URL, filename, etc. | ||
*/ | ||
export declare const slugSchema: import("./joi.extensions").ExtendedStringSchema; | ||
export declare const unixTimestampSchema: import("./joi.extensions").ExtendedNumberSchema; | ||
@@ -15,0 +23,0 @@ export declare const verSchema: import("./joi.extensions").ExtendedNumberSchema; |
@@ -21,2 +21,13 @@ "use strict"; | ||
.max(64); | ||
/** | ||
* `_` should NOT be allowed to be able to use slug-ids as part of natural ids with `_` separator. | ||
*/ | ||
exports.SLUG_PATTERN = /^[a-z0-9-]*$/; | ||
/** | ||
* "Slug" - a valid URL, filename, etc. | ||
*/ | ||
exports.slugSchema = exports.stringSchema | ||
.regex(exports.SLUG_PATTERN) | ||
.min(1) | ||
.max(255); | ||
// 16725225600 is 2500-01-01 | ||
@@ -23,0 +34,0 @@ exports.unixTimestampSchema = exports.numberSchema |
@@ -8,3 +8,4 @@ import { AppError } from '@naturalcycles/js-lib'; | ||
export declare class JoiValidationError extends AppError { | ||
data: JoiValidationErrorData; | ||
constructor(message: string, data: JoiValidationErrorData); | ||
} |
@@ -7,2 +7,3 @@ "use strict"; | ||
super(message, data); | ||
this.data = data; | ||
} | ||
@@ -9,0 +10,0 @@ } |
{ | ||
"name": "@naturalcycles/nodejs-lib", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "build": "del ./dist && tsc", |
@@ -24,2 +24,15 @@ import { SchemaMap } from 'joi' | ||
/** | ||
* `_` should NOT be allowed to be able to use slug-ids as part of natural ids with `_` separator. | ||
*/ | ||
export const SLUG_PATTERN = /^[a-z0-9-]*$/ | ||
/** | ||
* "Slug" - a valid URL, filename, etc. | ||
*/ | ||
export const slugSchema = stringSchema | ||
.regex(SLUG_PATTERN) | ||
.min(1) | ||
.max(255) | ||
// 16725225600 is 2500-01-01 | ||
@@ -26,0 +39,0 @@ export const unixTimestampSchema = numberSchema |
@@ -10,5 +10,5 @@ import { AppError } from '@naturalcycles/js-lib' | ||
export class JoiValidationError extends AppError { | ||
constructor (message: string, data: JoiValidationErrorData) { | ||
constructor (message: string, public data: JoiValidationErrorData) { | ||
super(message, data) | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
45329
886