Skip to main content
Glama
validateString.ts833 B
/** * Validates a string field. * @param value The value to validate. * @param entityName The name of the entity being validated. * @param minLength The minimum length of the string. * @param maxLength The maximum length of the string. * @returns An array of validation errors. */ export const validateString = ( value: unknown, entityName: string, minLength?: number, maxLength?: number ): string[] => { const errors: string[] = []; if (typeof value !== 'string') { errors.push(`${entityName} must be a string.`); } else if (minLength && value.length < minLength) { errors.push(`${entityName} must be at least ${minLength} characters long.`); } else if (maxLength && value.length > maxLength) { errors.push(`${entityName} must be at most ${maxLength} characters long.`); } return errors; };

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/aymericzip/intlayer'

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