Skip to content

Commit

Permalink
group: parent_id can be zero
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Feb 25, 2024
1 parent 9eb88e1 commit b81554d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

### Unreleased


### [0.7.1] - 2024-02-24

- group: parent_id can be zero

### [0.7.0] - 2024-02-24

- session: split to separate file
- user: sessionPost -> session.POST
- test: switch file names to \*.test.js
- group: added GET & POST
- shared: added meta

### [0.6.3] - 2024-02-23

- replace mocha with node's test runner
Expand All @@ -15,3 +28,5 @@
- add group & permission

[0.6.3]: https://github.com/NicTool/validate/releases/tag/0.6.3
[0.7.0]: https://github.com/NicTool/validate/releases/tag/0.7.0
[0.7.1]: https://github.com/NicTool/validate/releases/tag/0.7.1
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
for (const l of ['group', 'user', 'nameserver', 'zone', 'zone_record']) {
for (const l of [
'group',
'user',
'session',
'nameserver',
'zone',
'zone_record',
]) {
module.exports[l] = require(`./lib/${l}`)
}
10 changes: 6 additions & 4 deletions lib/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const shared = require('./shared')

exports.id = Joi.number().integer().min(1).max(4294967295)

exports.pid = Joi.number().integer().min(0).max(4294967295)

exports.name = Joi.string()
.min(3)
.max(255)
Expand All @@ -12,7 +14,7 @@ exports.name = Joi.string()

exports.v3 = Joi.object({
id: exports.id,
parent_gid: Joi.number().integer().greater(-1),
parent_gid: exports.pid,
name: exports.name.required(),
deleted: Joi.boolean(),
has_children: Joi.boolean(),
Expand All @@ -22,7 +24,7 @@ exports.v3 = Joi.object({
// legacy group format
exports.v2 = Joi.object({
nt_group_id: exports.id,
parent_group_id: Joi.number().integer().greater(-1),
parent_group_id: exports.pid,
name: exports.name.required(),
deleted: Joi.boolean(),
has_children: Joi.boolean(),
Expand All @@ -31,7 +33,7 @@ exports.v2 = Joi.object({

exports.GET = Joi.object({
group: Joi.object({
id: exports.id,
id: exports.pid,
name: exports.name,
}),
meta: shared.meta,
Expand All @@ -40,5 +42,5 @@ exports.GET = Joi.object({
exports.POST = Joi.object({
id: exports.id,
name: exports.name,
parent_gid: exports.id,
parent_gid: exports.pid,
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nictool/validate",
"version": "0.7.0",
"version": "0.7.1",
"description": "NicTool Object Validation",
"main": "index.js",
"directories": {
Expand Down

0 comments on commit b81554d

Please sign in to comment.