How to use @expo/schemer - 3 common examples

To help you get started, we’ve selected a few @expo/schemer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo-cli / packages / xdl / src / project / Doctor.ts View on Github external
export async function validateWithSchema(
  projectRoot: string,
  exp: any,
  schema: any,
  configName: string,
  sdkVersion: string,
  validateAssets: boolean
): Promise<{ schemaErrorMessage: string | undefined; assetsErrorMessage: string | undefined }> {
  let schemaErrorMessage;
  let assetsErrorMessage;
  let validator = new Schemer(schema, { rootDir: projectRoot });

  // Validate the schema itself
  try {
    await validator.validateSchemaAsync(exp);
  } catch (e) {
    if (e instanceof SchemerError) {
      schemaErrorMessage = `Error: Problem${
        e.errors.length > 1 ? 's' : ''
      } validating fields in ${configName}. See https://docs.expo.io/versions/v${sdkVersion}/workflow/configuration/`;
      schemaErrorMessage += e.errors.map(formatValidationError).join('');
    }
  }

  if (validateAssets) {
    try {
      await validator.validateAssetsAsync(exp);
github expo / expo-cli / packages / xdl / src / project / ExpSchema.ts View on Github external
export async function validatorFromProjectRoot(projectRoot: string): Promise {
  const { exp } = await ConfigUtils.readConfigJsonAsync(projectRoot);
  if (!exp.sdkVersion) throw new Error(`Couldn't read local manifest`);
  const schema = await getSchemaAsync(exp.sdkVersion);
  const validator = new Schemer(schema);
  return validator;
}
github expo / expo-cli / dev / xdl / src / project / ExpSchema.js View on Github external
export async function validatorFromProjectRoot(projectRoot: string): Schemer {
  const { exp } = await ProjectUtils.readConfigJsonAsync(projectRoot);
  if (!exp) throw new Error(`Couldn't read local manifest`);
  const schema = await getSchemaAsync(exp.sdkVersion);
  const validator = new Schemer(schema);
  return validator;
}

@expo/schemer

Centralized scheme validation library for Expo

MIT
Latest version published 2 months ago

Package Health Score

89 / 100
Full package analysis

Popular @expo/schemer functions