Skip to content

Commit b4ecf93

Browse files
committed
revert changes to faker method validation logic
1 parent d907bce commit b4ecf93

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

packages/compass-collection/src/modules/collection-tab.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -721,21 +721,11 @@ const validateFakerSchema = (
721721
const { fakerMethod } = field;
722722

723723
// validate faker method
724-
const methodSegments = fakerMethod.split('.');
725-
let methodRef: any = faker;
726-
for (const segment of methodSegments) {
727-
if (
728-
methodRef &&
729-
typeof methodRef === 'object' &&
730-
segment in methodRef
731-
) {
732-
methodRef = methodRef[segment];
733-
} else {
734-
methodRef = undefined;
735-
break;
736-
}
737-
}
738-
if (typeof methodRef !== 'function') {
724+
const [moduleName, methodName, ...rest] = fakerMethod.split('.');
725+
if (
726+
rest.length > 0 ||
727+
typeof (faker as any)[moduleName]?.[methodName] !== 'function'
728+
) {
739729
logger.log.warn(
740730
mongoLogId(1_001_000_372),
741731
'Collection',

0 commit comments

Comments
 (0)