File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ toolchain go1.23.4
66
77require (
88 github.com/gobwas/glob v0.2.3
9+ github.com/pkg/errors v0.9.1
910 github.com/stretchr/testify v1.10.0
1011 gopkg.in/yaml.v3 v3.0.1
1112)
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
1212github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY =
1313github.com/kr/text v0.2.0 /go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE =
1414github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e /go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA =
15+ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4 =
16+ github.com/pkg/errors v0.9.1 /go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0 =
1517github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM =
1618github.com/pmezard/go-difflib v1.0.0 /go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4 =
1719github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs =
Original file line number Diff line number Diff line change 11package validator
22
33import (
4+ "context"
5+
46 "github.com/nullify-platform/config-file-parser/pkg/models"
7+ "github.com/nullify-platform/config-file-parser/pkg/parser"
8+ "github.com/pkg/errors"
59)
610
711// ValidateConfig return true if provided configuration is valid
@@ -12,3 +16,13 @@ func ValidateConfig(config *models.Configuration) bool {
1216 ValidatePaths (config ) &&
1317 ValidateAutoFix (config )
1418}
19+
20+ func IsConfigValid (ctx context.Context , configString string ) (bool , error ) {
21+ parsedConfig , err := parser .ParseConfiguration ([]byte (configString ))
22+ if err != nil {
23+ return false , errors .Wrap (err , "failed to parse config" )
24+ }
25+
26+ isValid := ValidateConfig (parsedConfig )
27+ return isValid , nil
28+ }
You can’t perform that action at this time.
0 commit comments