Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e93fdfb

Browse files
committed
schema: Add regex patterns
1 parent 6e2f310 commit e93fdfb

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

lua/packspec/schema.lua

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
local pat_version = [[([0-9]|[1-9][0-9]*)(\.([0-9]|[1-9][0-9]*))*]]
2+
local pat_range = [[((==|~=|<|>|<=|>=|~>)\s*)?]]..pat_version
3+
4+
local PAT_VERSION = "^"..pat_version.."$"
5+
local PAT_RANGE = "^"..pat_range..[[(\s*,\s*]]..pat_range..[[)*$]]
6+
local PAT_URL = [[^(file|git(\+(https?|ssh))?|https?)://]]
7+
18
return {
29
title = "PlugSpec",
310
description = "A PlugSpec for a Neovim plugin",
@@ -16,13 +23,13 @@ return {
1623
implementation should check for a `version` prefixed with `v` in the
1724
git repository, as this is a common convention.
1825
]],
19-
-- TODO: specify format
2026
type = "string",
27+
pattern = PAT_VERSION,
2128
},
2229
packspec = {
2330
description = "The current specification version. (0.1.0) at this time.",
24-
-- TODO: specify format
25-
type = "string"
31+
type = "string",
32+
pattern = PAT_VERSION,
2633
},
2734
source = {
2835
description = [[
@@ -43,6 +50,7 @@ return {
4350
* `https://` - for HTTPS URLs
4451
]],
4552
type = "string",
53+
pattern = PAT_URL,
4654
},
4755
description = {
4856
description = "Description of the package",
@@ -108,14 +116,15 @@ return {
108116
corresponding to that upper bound is the latest commit that
109117
is valid
110118
]],
111-
-- TODO: specify format
112-
type = 'string'
119+
type = 'string',
120+
pattern = PAT_RANGE,
113121
},
114122
source = {
115123
description = [[
116124
Source of the dependency. See previous `source` description.
117125
]],
118-
type = 'string'
126+
type = 'string',
127+
pattern = PAT_URL,
119128
},
120129
releases_only = {
121130
description = [[
@@ -143,7 +152,8 @@ return {
143152
properties = {
144153
version = {
145154
description = "Same as `dependencies`",
146-
type = 'string'
155+
type = 'string',
156+
pattern = PAT_RANGE,
147157
}
148158
}
149159
}

0 commit comments

Comments
 (0)