Skip to content

Commit

Permalink
Merge branch 'master' into users/t-abaskar/persistence-yaml-validator…
Browse files Browse the repository at this point in the history
…-pac
  • Loading branch information
abaskk-msft committed Jul 17, 2024
2 parents 54b9b17 + 1cf22bb commit be6a1bf
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/Persistence/YamlValidator/ValidationProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.PowerPlatform.PowerApps.Persistence.YamlValidator;

public class ValidationProcessor
{
private readonly YamlLoader _fileLoader;

Check failure on line 8 in src/Persistence/YamlValidator/ValidationProcessor.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

The type or namespace name 'YamlLoader' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in src/Persistence/YamlValidator/ValidationProcessor.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

The type or namespace name 'YamlLoader' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 8 in src/Persistence/YamlValidator/ValidationProcessor.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'YamlLoader' could not be found (are you missing a using directive or an assembly reference?)
private readonly SchemaLoader _schemaLoader;
private readonly Validator _validator;

public ValidationProcessor(YamlLoader fileLoader, SchemaLoader schemaLoader, Validator validator)

Check failure on line 12 in src/Persistence/YamlValidator/ValidationProcessor.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

The type or namespace name 'YamlLoader' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 12 in src/Persistence/YamlValidator/ValidationProcessor.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Inconsistent accessibility: parameter type 'Validator' is less accessible than method 'ValidationProcessor.ValidationProcessor(YamlLoader, SchemaLoader, Validator)'

Check failure on line 12 in src/Persistence/YamlValidator/ValidationProcessor.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

The type or namespace name 'YamlLoader' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 12 in src/Persistence/YamlValidator/ValidationProcessor.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Inconsistent accessibility: parameter type 'Validator' is less accessible than method 'ValidationProcessor.ValidationProcessor(YamlLoader, SchemaLoader, Validator)'

Check failure on line 12 in src/Persistence/YamlValidator/ValidationProcessor.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'YamlLoader' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 12 in src/Persistence/YamlValidator/ValidationProcessor.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Inconsistent accessibility: parameter type 'Validator' is less accessible than method 'ValidationProcessor.ValidationProcessor(YamlLoader, SchemaLoader, Validator)'
{
_fileLoader = fileLoader;
_schemaLoader = schemaLoader;
_validator = validator;
}

public void RunValidation(ValidationRequest inputData)
{
var path = inputData.FilePath;
var pathType = inputData.FilePathType;

var yamlData = _fileLoader.Load(path, pathType);
var serializedSchema = _schemaLoader.Load();

foreach (var yamlFileData in yamlData)
{
Console.WriteLine($"Validating '{yamlFileData.Key}'");
var result = _validator.Validate(serializedSchema, yamlFileData.Value);
Console.WriteLine($"Validation {(result.SchemaValid ? "Passed" : "Failed")}");

foreach (var error in result.TraversalResults)
{
Console.WriteLine($"{error}");
}
Console.WriteLine();
}
}
}
6 changes: 6 additions & 0 deletions src/Persistence/YamlValidator/ValidationRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Microsoft.PowerPlatform.PowerApps.Persistence.YamlValidator;

public readonly record struct ValidationRequest(string FilePath, string FilePathType);
Empty file.
Empty file.
1 change: 1 addition & 0 deletions src/YamlValidator/ValidationRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit be6a1bf

Please sign in to comment.