# generaltranslation: General Translation Core SDK: isValidLocale URL: https://generaltranslation.com/en-GB/docs/core/functions/locales/is-valid-locale.mdx --- title: isValidLocale description: API reference for the isValidLocale function --- ## Overview The `isValidLocale` function validates whether a given string represents a valid BCP-47 locale code. It performs comprehensive format validation without requiring a GT class instance. *** ## Reference ### Parameters ### Returns `boolean` - `true` if the locale code is valid, `false` otherwise *** ## Examples ```typescript import { isValidLocale } from 'generaltranslation'; // Valid locale codes console.log(isValidLocale('en-US')); // true console.log(isValidLocale('zh-CN')); // true console.log(isValidLocale('es')); // true // Invalid locale codes console.log(isValidLocale('invalid')); // false console.log(isValidLocale('en_US')); // false (underscore instead of hyphen) console.log(isValidLocale('')); // false ``` *** ## Notes * Validates BCP-47 locale code format * Works with custom locale mappings * Essential for user input validation * No network requests – pure format validation * Stateless function suitable for utility libraries ## Next steps * Use the GT class method [`isValidLocale`](/docs/core/class/methods/locales/is-valid-locale) * Standardise the format with [`standardizeLocale`](/docs/core/functions/locales/standardize-locale)