mongodb-memory-bank-mcp
Version:
FIXED: MongoDB Memory Bank MCP with bulletproof error handling, smart operations, and session state management. Eliminates [object Object] errors and user confusion.
22 lines (21 loc) • 615 B
JavaScript
import { InvalidParamError } from "../presentation/errors/index.js";
import { NAME_REGEX } from "./constants.js";
export class ParamNameValidator {
fieldName;
regex;
constructor(fieldName, regex = NAME_REGEX) {
this.fieldName = fieldName;
this.regex = regex;
}
validate(input) {
if (!input || !input[this.fieldName]) {
return null;
}
const paramName = input[this.fieldName];
const isValid = this.regex.test(paramName);
if (!isValid) {
return new InvalidParamError(paramName);
}
return null;
}
}