Comparing version 0.1.1 to 0.1.2
@@ -27,3 +27,7 @@ "use strict"; | ||
}, | ||
unique(value, group = '', context) { | ||
unique(value, group, context, tagUniqueId) { | ||
let groupName = group || 'value'; | ||
if (!group) { | ||
group = tagUniqueId; | ||
} | ||
let { uniqueSetMap } = context; | ||
@@ -39,3 +43,3 @@ if (!uniqueSetMap) { | ||
if (uniqueSet.has(value)) { | ||
return `Duplicate ${group || 'value'} ${JSON.stringify(value)}`; | ||
return `Duplicate ${groupName} ${JSON.stringify(value)}`; | ||
} | ||
@@ -42,0 +46,0 @@ uniqueSet.add(value); |
@@ -12,3 +12,3 @@ import { Dict } from 'tslang'; | ||
*/ | ||
export declare type ValidatorExtension<TContext extends object = object> = (value: unknown, comment: string | undefined, context: TContext) => string | undefined; | ||
export declare type ValidatorExtension<TContext extends object = object> = (value: unknown, comment: string | undefined, context: TContext, tagUniqueId: string) => string | undefined; | ||
export declare type ValidatorExtensions<TContext extends object = object> = Dict<ValidatorExtension<TContext>>; | ||
@@ -15,0 +15,0 @@ export interface ValidatorOptions { |
@@ -94,3 +94,4 @@ "use strict"; | ||
let comment = tag.comment; | ||
let reason = extension(value, comment, this.context); | ||
let tagUniqueId = `${tag.getSourceFile().fileName}:${tag.getStart()}`; | ||
let reason = extension(value, comment, this.context, tagUniqueId); | ||
if (typeof reason === 'string') { | ||
@@ -97,0 +98,0 @@ extensionReasons.push(reason); |
{ | ||
"name": "tiva", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Expensive plain object type validator leverages TypeScript language service.", | ||
@@ -24,3 +24,3 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@magicspace/configs": "^0.2.1", | ||
"@magicspace/configs": "^0.2.2", | ||
"@magicspace/eslint-plugin": "^0.1.2", | ||
@@ -30,3 +30,2 @@ "@types/node": "^12.12.3", | ||
"eslint": "^6.6.0", | ||
"eslint-config-prettier": "^6.5.0", | ||
"prettier": "^1.19.0" | ||
@@ -33,0 +32,0 @@ }, |
@@ -6,3 +6,3 @@ [![NPM Package](https://badge.fury.io/js/tiva.svg)](https://www.npmjs.com/package/tiva) | ||
🤧 EXPENSIVE plain object type validator leverages TypeScript language service. | ||
⏱️ EXPENSIVE plain object type validator leverages TypeScript language service. | ||
@@ -9,0 +9,0 @@ ## Usage |
@@ -42,3 +42,9 @@ import {isUUID} from 'validator'; | ||
}, | ||
unique(value, group = '', context) { | ||
unique(value, group, context, tagUniqueId) { | ||
let groupName = group || 'value'; | ||
if (!group) { | ||
group = tagUniqueId; | ||
} | ||
let {uniqueSetMap} = context; | ||
@@ -58,3 +64,3 @@ | ||
if (uniqueSet.has(value)) { | ||
return `Duplicate ${group || 'value'} ${JSON.stringify(value)}`; | ||
return `Duplicate ${groupName} ${JSON.stringify(value)}`; | ||
} | ||
@@ -61,0 +67,0 @@ |
@@ -51,2 +51,3 @@ import * as Path from 'path'; | ||
context: TContext, | ||
tagUniqueId: string, | ||
) => string | undefined; | ||
@@ -226,4 +227,7 @@ | ||
let comment = tag.comment; | ||
let tagUniqueId = `${ | ||
tag.getSourceFile().fileName | ||
}:${tag.getStart()}`; | ||
let reason = extension(value, comment, this.context); | ||
let reason = extension(value, comment, this.context, tagUniqueId); | ||
@@ -230,0 +234,0 @@ if (typeof reason === 'string') { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55180
6
1004