|
4 | 4 | [](https://github.com/aboutcode-org/purlvalidator-go/releases) |
5 | 5 | [](https://github.com/aboutcode-org/purlvalidator-go/actions) |
6 | 6 |
|
7 | | -**purlvalidator** is a Go library for validating [Package URLs (PURLs)](https://github.com/package-url/purl-spec). It works fully offline, including in **air-gapped** or **restricted environments**, and answers one key question: **Does the package this PURL represents actually exist?** |
| 7 | +**purlvalidator** is a Go library for validating [Package-URLs (PURLs)](https://github.com/package-url/purl-spec). It works fully offline, including in **air-gapped** or **restricted environments**, and answers one key question: **Does the package this PURL represents actually exist?** |
8 | 8 |
|
9 | 9 | ## How It Works? |
10 | 10 |
|
11 | | -**purlvalidator** is shipped with a pre-built FST (Finite State Transducer), a set of compact automata containing latest Package URLs mined by the MineCode[^1]. Library uses this FST to perform lookups and confirm whether the **base PURL**[^2] exists. |
| 11 | +**purlvalidator** is shipped with a pre-built FST (Finite State Transducer), a set of compact automata containing latest Package-URLs mined by the MineCode[^1]. Library uses this FST to perform lookups and confirm whether the **base PURL**[^2] exists. |
12 | 12 |
|
13 | 13 | ## Currently Supported Ecosystems |
14 | 14 |
|
|
30 | 30 | Add `purlvalidator` as dependency in your go.mod |
31 | 31 |
|
32 | 32 | ```bash |
33 | | -require github.com/aboutcode-org/purlvalidator-go v0.1.0 |
| 33 | +require github.com/aboutcode-org/purlvalidator-go v1.0.0 |
34 | 34 | ``` |
35 | 35 |
|
36 | | -Use it in your code like this |
| 36 | +Use it in your code like this: |
37 | 37 |
|
38 | | -```rust |
| 38 | +```go |
39 | 39 | import "github.com/aboutcode-org/purlvalidator-go" |
40 | 40 |
|
41 | | -var result bool = purlvalidator.Validate("pkg:nuget/FluentValidation"); |
| 41 | +func main() { |
| 42 | + result, e := purlvalidator.Validate("pkg:nuget/FluentValidation"); |
| 43 | + if err != nil { |
| 44 | + panic(err) |
| 45 | + } |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +Examples and errors: |
| 50 | +```go |
| 51 | +// This will return: true |
| 52 | +purlvalidator.Validate("pkg:nuget/FluentValidation"); |
| 53 | + |
| 54 | +// This will return: false |
| 55 | +purlvalidator.Validate("pkg:nuget/non-existent-foo-bar"); |
| 56 | + |
| 57 | + |
| 58 | +// This will return an error: "only base PURL is supported (no version, qualifiers, or subpath)" |
| 59 | +purlvalidator.Validate("pkg:nuget/FluentValidation@10.2.3"); |
| 60 | + |
| 61 | +// This will return an error: "purl scheme is not \"pkg\": \"pkddg\"" |
| 62 | +purlvalidator.Validate("test:nuget/FluentValidation"); |
| 63 | + |
42 | 64 | ``` |
43 | 65 |
|
44 | 66 | ## Contribution |
@@ -90,4 +112,4 @@ limitations under the License. |
90 | 112 | ``` |
91 | 113 |
|
92 | 114 | [^1]: MineCode continuously collects package metadata from various package ecosystems to maintain an up-to-date catalog of known packages. |
93 | | -[^2]: A Base Package URL is a Package URL without a version or subpath. |
| 115 | +[^2]: A Base Package-URL is a Package-URL without a version, qualifiers or subpath. |
0 commit comments