(ctx *ValidationContext, obj *model.Repository)
| 117 | } |
| 118 | |
| 119 | func validateRepository(ctx *ValidationContext, obj *model.Repository) *ValidationResult { |
| 120 | result := &ValidationResult{Valid: true, Issues: []ValidationIssue{}} |
| 121 | |
| 122 | // Skip validation if repository is nil or empty (optional field) |
| 123 | if obj == nil || (obj.URL == "" && obj.Source == "") { |
| 124 | return result |
| 125 | } |
| 126 | |
| 127 | // validate the repository source |
| 128 | repoSource := RepositorySource(obj.Source) |
| 129 | if !IsValidRepositoryURL(repoSource, obj.URL) { |
| 130 | issue := NewValidationIssueFromError( |
| 131 | ValidationIssueTypeSemantic, |
| 132 | ctx.Field("url").String(), |
| 133 | fmt.Errorf("%w: %s", ErrInvalidRepositoryURL, obj.URL), |
| 134 | "invalid-repository-url", |
| 135 | ) |
| 136 | result.AddIssue(issue) |
| 137 | } |
| 138 | |
| 139 | // validate subfolder if present |
| 140 | if obj.Subfolder != "" && !IsValidSubfolderPath(obj.Subfolder) { |
| 141 | issue := NewValidationIssueFromError( |
| 142 | ValidationIssueTypeSemantic, |
| 143 | ctx.Field("subfolder").String(), |
| 144 | fmt.Errorf("%w: %s", ErrInvalidSubfolderPath, obj.Subfolder), |
| 145 | "invalid-subfolder-path", |
| 146 | ) |
| 147 | result.AddIssue(issue) |
| 148 | } |
| 149 | |
| 150 | return result |
| 151 | } |
| 152 | |
| 153 | func validateWebsiteURL(ctx *ValidationContext, websiteURL string) *ValidationResult { |
| 154 | result := &ValidationResult{Valid: true, Issues: []ValidationIssue{}} |
no test coverage detected
searching dependent graphs…