Make it allright not to provide validators object on mock data
This commit is contained in:
parent
6d9e62d2b4
commit
e4a46f31de
@ -60,6 +60,8 @@ export function getKcContext<KcContextExtended extends { pageId: string } = neve
|
|||||||
].filter(exclude(undefined));
|
].filter(exclude(undefined));
|
||||||
|
|
||||||
attributes.forEach(attribute => {
|
attributes.forEach(attribute => {
|
||||||
|
console.log("====>", attribute);
|
||||||
|
|
||||||
const partialAttribute = partialAttributes.find(({ name }) => name === attribute.name);
|
const partialAttribute = partialAttributes.find(({ name }) => name === attribute.name);
|
||||||
|
|
||||||
const augmentedAttribute: Attribute = {} as any;
|
const augmentedAttribute: Attribute = {} as any;
|
||||||
@ -82,14 +84,16 @@ export function getKcContext<KcContextExtended extends { pageId: string } = neve
|
|||||||
id<KcContextBase.RegisterUserProfile>(kcContext).profile.attributesByName[augmentedAttribute.name] = augmentedAttribute;
|
id<KcContextBase.RegisterUserProfile>(kcContext).profile.attributesByName[augmentedAttribute.name] = augmentedAttribute;
|
||||||
});
|
});
|
||||||
|
|
||||||
partialAttributes.forEach(partialAttribute => {
|
partialAttributes
|
||||||
const { name } = partialAttribute;
|
.map(partialAttribute => ({ "validators": {}, ...partialAttribute }))
|
||||||
|
.forEach(partialAttribute => {
|
||||||
|
const { name } = partialAttribute;
|
||||||
|
|
||||||
assert(name !== undefined, "If you define a mock attribute it must have at least a name");
|
assert(name !== undefined, "If you define a mock attribute it must have at least a name");
|
||||||
|
|
||||||
id<KcContextBase.RegisterUserProfile>(kcContext).profile.attributes.push(partialAttribute as any);
|
id<KcContextBase.RegisterUserProfile>(kcContext).profile.attributes.push(partialAttribute as any);
|
||||||
id<KcContextBase.RegisterUserProfile>(kcContext).profile.attributesByName[name] = partialAttribute as any;
|
id<KcContextBase.RegisterUserProfile>(kcContext).profile.attributesByName[name] = partialAttribute as any;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user