You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Person {
@IsValueIn(['PETER', 'JAMES'])
@IsAlpha()
@IsDefined()
public name:string;
}
When this demo is run it logs the following:
Error in /turbo_modules/@fireflysemantics/validator@3.0.10/bundles/fireflysemantics-validator.umd.js (194:21)
The ValidationContainer
already contains context with signature IsValueIn_Person_name.
This is because the runtime decorator @IsValueIn(['PETER', 'JAMES']) is called twice.
I've added logging statements to the @fireflysemantics/validator library such that this can be seen more clearly:
That is the function that gets called by the decorator.
/**
* @param target Add a ValidationContext instance.
* @throws Error if attempting to add a ValidationContext with a signature that duplicates that of an instance already contained.
*
* If an exception thrown it indicates that a duplicate class definition exist
* in the runtime. In other words the same class definition is loaded more
* than once because it exists in multiple files.
*
*/
public static addValidationContext(target: ValidationContext): void {
const key: string = getPropertyKey(
target.target.name,
target.propertyName
);
console.log("The property key is: ", key)
console.log("The target signature is: ", target.getSignature())
Expected behavior:
These statements should only execute one time for each decorator:
console.log("The property key is: ", key)
console.log("The target signature is: ", target.getSignature())
Actual behavior:
However they get called twice for the @IsValueIn(['PETER', 'JAMES']) decorator.
Try commenting out @IsValueIn(['PETER', 'JAMES']) and you will see there are no exceptions.
Here's a stackblitz demo:
https://stackblitz.com/edit/typescript-fs-validator-typescript-issue-reported?file=index.ts
When this demo is run it logs the following:
This is because the runtime decorator
@IsValueIn(['PETER', 'JAMES'])
is called twice.I've added logging statements to the @fireflysemantics/validator library such that this can be seen more clearly:
https://github.com/fireflysemantics/validator/blob/master/projects/validator/src/lib/ValidationContainer.ts#L61
That is the function that gets called by the decorator.
Expected behavior:
These statements should only execute one time for each decorator:
Actual behavior:
However they get called twice for the
@IsValueIn(['PETER', 'JAMES'])
decorator.Try commenting out
@IsValueIn(['PETER', 'JAMES'])
and you will see there are no exceptions.Playground Link:
https://stackblitz.com/edit/typescript-fs-validator-typescript-issue-reported?file=index.ts
The text was updated successfully, but these errors were encountered: