Skip to main content
Glama
validation.ts1.29 kB
/** * Validates if a string is a valid Figma file key. * File keys are typically alphanumeric strings. */ export const isValidFileKey = (fileKey: string): boolean => { if (!fileKey || typeof fileKey !== "string") { return false; } return /^[a-zA-Z0-9]{20,30}$/.test(fileKey); }; /** * Validates if a string is a valid Figma node ID. * Node IDs can contain numbers, letters, colons, and hyphens. */ export const isValidNodeId = (nodeId: string): boolean => { if (!nodeId || typeof nodeId !== "string") { return false; } return /^[a-zA-Z0-9:;\-]+$/.test(nodeId); }; /** * Validation result type */ export interface ValidationResult { isValid: boolean; error?: string; } /** * Validates environment variables. */ export const validateApiToken = (token: string): ValidationResult => { if (!token) { return { isValid: false, error: "API token is required" }; } if (typeof token !== "string") { return { isValid: false, error: "API token must be a string" }; } if (token.length < 40 || token.length > 50) { return { isValid: false, error: "Invalid API token format" }; } if (!/^[a-zA-Z0-9\-_]+$/.test(token)) { return { isValid: false, error: "API token contains invalid characters" }; } return { isValid: true }; };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/toddle-edu/figma-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server