MCPcopy Create free account
hub / github.com/vercel/vercel / validateConfig

Function validateConfig

packages/cli/src/util/validate-config.ts:631–764  ·  view source on GitHub ↗
(config: VercelConfig)

Source from the content-addressed store, hash-verified

629}
630
631export function validateConfig(config: VercelConfig): NowBuildError | null {
632 const validate = getConfigValidator();
633 if (!validate(config)) {
634 if (validate.errors && validate.errors[0]) {
635 const error = validate.errors[0];
636 const fileName = config[fileNameSymbol] || 'vercel.json';
637 const niceError = getPrettyError(error);
638 niceError.message = `Invalid ${fileName} - ${niceError.message}`;
639 return niceError;
640 }
641 }
642
643 if (config.functions && config.builds) {
644 return new NowBuildError({
645 code: 'FUNCTIONS_AND_BUILDS',
646 message:
647 'The `functions` property cannot be used in conjunction with the `builds` property. Please remove one of them.',
648 link: 'https://vercel.link/functions-and-builds',
649 });
650 }
651
652 const hasExperimentalServices = Boolean(config.experimentalServices);
653
654 if (hasExperimentalServices && config.builds) {
655 return new NowBuildError({
656 code: 'EXPERIMENTAL_SERVICES_AND_BUILDS',
657 message:
658 'The `experimentalServices` property cannot be used in conjunction with the `builds` property. Please remove one of them.',
659 });
660 }
661
662 if (hasExperimentalServices && config.functions) {
663 return new NowBuildError({
664 code: 'EXPERIMENTAL_SERVICES_AND_FUNCTIONS',
665 message:
666 'The `experimentalServices` property cannot be used in conjunction with the `functions` property. Please remove one of them.',
667 });
668 }
669
670 if (config.experimentalServiceGroups && !config.experimentalServices) {
671 return new NowBuildError({
672 code: 'SERVICE_GROUPS_WITHOUT_SERVICES',
673 message:
674 'The `experimentalServiceGroups` property requires `experimentalServices` to be defined. Service groups reference services by name.',
675 });
676 }
677
678 const hasServices = config.services != null;
679 const hasExperimentalServicesV2 = config.experimentalServicesV2 != null;
680
681 if (hasServices && hasExperimentalServicesV2) {
682 return new NowBuildError({
683 code: 'SERVICES_AND_EXPERIMENTAL_SERVICES_V2',
684 message:
685 'The `services` property cannot be used in conjunction with its deprecated alias `experimentalServicesV2`. Please use only `services`.',
686 });
687 }
688

Callers 3

validate.test.tsFile · 0.90
validateVercelConfigMethod · 0.90

Calls 7

getPrettyErrorFunction · 0.90
getConfigValidatorFunction · 0.85
pushMethod · 0.65
validateFunction · 0.50
joinMethod · 0.45
keysMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected