-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
…-pac
- Loading branch information
There are no files selected for viewing
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 GitHub Actions / build (macos-latest)
Check failure on line 8 in src/Persistence/YamlValidator/ValidationProcessor.cs GitHub Actions / build (macos-latest)
|
||
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 GitHub Actions / build (macos-latest)
Check failure on line 12 in src/Persistence/YamlValidator/ValidationProcessor.cs GitHub Actions / build (macos-latest)
Check failure on line 12 in src/Persistence/YamlValidator/ValidationProcessor.cs GitHub Actions / build (macos-latest)
Check failure on line 12 in src/Persistence/YamlValidator/ValidationProcessor.cs GitHub Actions / build (macos-latest)
Check failure on line 12 in src/Persistence/YamlValidator/ValidationProcessor.cs GitHub Actions / build (ubuntu-latest)
Check failure on line 12 in src/Persistence/YamlValidator/ValidationProcessor.cs GitHub Actions / build (ubuntu-latest)
|
||
{ | ||
_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(); | ||
} | ||
} | ||
} |
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); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|