Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
name: CI

on:
push:
branches-ignore:
- 'dependabot/**' #avoid duplicates: run the PR, not the push
tags-ignore:
- 'v*' #avoid rerun existing commit on release
pull_request:
types: [opened, synchronize, reopened]

env:
CI: true
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
name: publish

on:
push:
branches:
- main
paths:
- package.json
release:
types: [published]
release:
types: [published]

env:
CI: true
Expand Down
3 changes: 0 additions & 3 deletions .prettierrc.yml

This file was deleted.

20 changes: 15 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

### Unreleased

### [0.8.3] - 2026-03-13

- ns: NSD -> nsd
- user: user is now an array
- prettier: move config into package.json
- zone: last publish can be all zeroes
- zone_rec: expanded valid RR types & all the fields that go with them
- ESM: dual export with wrapper
- deps: bump all to latest

### [0.8.2] - 2025-04-08

- feat(zone_record): added GET, POST, and DELETE formats
Expand Down Expand Up @@ -77,13 +87,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
[0.5.0]: https://github.com/NicTool/validate/releases/tag/0.5.0
[0.6.0]: https://github.com/NicTool/validate/releases/tag/0.6.0
[0.6.1]: https://github.com/NicTool/validate/releases/tag/0.6.1
[0.6.3]: https://github.com/NicTool/validate/releases/tag/0.6.3
[0.6.3]: https://github.com/NicTool/validate/releases/tag/v0.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
[0.7.1]: https://github.com/NicTool/validate/releases/tag/v0.7.1
[0.7.2]: https://github.com/NicTool/validate/releases/tag/0.7.2
[0.7.3]: https://github.com/NicTool/validate/releases/tag/0.7.3
[0.7.4]: https://github.com/NicTool/validate/releases/tag/0.7.4
[0.8.0]: https://github.com/NicTool/validate/releases/tag/0.8.0
[0.7.4]: https://github.com/NicTool/validate/releases/tag/v0.7.4
[0.8.0]: https://github.com/NicTool/validate/releases/tag/v0.8.0
[0.8.1]: https://github.com/NicTool/validate/releases/tag/v0.8.1
[0.8.2]: https://github.com/NicTool/validate/releases/tag/v0.8.2
[1.0.0]: https://github.com/NicTool/validate/releases/tag/1.0.0
[0.8.3]: https://github.com/NicTool/validate/releases/tag/v0.8.3
4 changes: 2 additions & 2 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Contributors

This handcrafted artisinal software is brought to you by:
This handcrafted artisanal software is brought to you by:

| <img height="80" src="https://avatars.githubusercontent.com/u/261635?v=4"><br><a href="https://github.com/msimerson">msimerson</a> (<a href="https://github.com/NicTool/validate/commits?author=msimerson">21</a>) |
| <img height="80" src="https://avatars.githubusercontent.com/u/261635?v=4"><br><a href="https://github.com/msimerson">msimerson</a> (<a href="https://github.com/NicTool/validate/commits?author=msimerson">22</a>) |
| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |

<sub>this file is generated by [.release](https://github.com/msimerson/.release).
Expand Down
17 changes: 4 additions & 13 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
import globals from 'globals'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import js from '@eslint/js'
import { FlatCompat } from '@eslint/eslintrc'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
})
import prettier from 'eslint-config-prettier'

export default [
{
ignores: ['**/package-lock.json'],
ignores: ['**/package-lock.json', 'node_modules/**', '.release/**'],
},
...compat.extends('eslint:recommended', 'prettier'),
js.configs.recommended,
prettier,
{
languageOptions: {
globals: {
Expand Down
10 changes: 1 addition & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
for (const l of [
'group',
'nameserver',
'permission',
'session',
'user',
'zone',
'zone_record',
]) {
for (const l of ['group', 'nameserver', 'permission', 'session', 'user', 'zone', 'zone_record']) {
module.exports[l] = require(`./lib/${l}`)
}
14 changes: 14 additions & 0 deletions index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)
const validate = require('./index.js')

export default validate

export const group = validate.group
export const nameserver = validate.nameserver
export const permission = validate.permission
export const session = validate.session
export const user = validate.user
export const zone = validate.zone
export const zone_record = validate.zone_record
5 changes: 1 addition & 4 deletions lib/group.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ describe('group', function () {

const { error, value } = schema.validate(testCase)

assert.strictEqual(
error.message,
'"name" length must be at least 3 characters long',
)
assert.strictEqual(error.message, '"name" length must be at least 3 characters long')
assert.deepEqual(value, testCase)
})

Expand Down
10 changes: 1 addition & 9 deletions lib/nameserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,7 @@ exports.name = Joi.string()
.domain({ allowFullyQualified: true, tlds: false })
.pattern(/\.$/)

exports.type = Joi.string().valid(
'bind',
'djbdns',
'knot',
'NSD',
'maradns',
'powerdns',
'dynect',
)
exports.type = Joi.string().valid('bind', 'djbdns', 'knot', 'nsd', 'maradns', 'powerdns', 'dynect')

exports.remote_login = Joi.string().empty('').max(127)

Expand Down
28 changes: 4 additions & 24 deletions lib/nameserver.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ describe('nameserver', function () {
})
}

const errMsgs = [
'"name" must be a valid hostname',
'"name" must contain a valid domain name',
]
const errMsgs = ['"name" must be a valid hostname', '"name" must contain a valid domain name']

const invalid_names = [
'-bad_ns',
Expand Down Expand Up @@ -77,15 +74,7 @@ describe('nameserver', function () {
assert.deepEqual(value, testCase)
})

for (const n of [
'bind',
'djbdns',
'knot',
'NSD',
'maradns',
'powerdns',
'dynect',
]) {
for (const n of ['bind', 'djbdns', 'knot', 'nsd', 'maradns', 'powerdns', 'dynect']) {
it(`accepts valid: ${n}`, () => {
const testCase = JSON.parse(JSON.stringify(testNS))
testCase.export.type = n
Expand All @@ -97,16 +86,7 @@ describe('nameserver', function () {
})
}

for (const n of [
'cryptic',
'fuzzy',
'yitizg',
'bin',
'djbs',
'DJB',
'BIND',
'NT',
]) {
for (const n of ['cryptic', 'fuzzy', 'yitizg', 'bin', 'djbs', 'DJB', 'BIND', 'NT']) {
it(`rejects invalid: ${n}`, () => {
const testCase = JSON.parse(JSON.stringify(testNS))
testCase.export.type = n
Expand All @@ -115,7 +95,7 @@ describe('nameserver', function () {

assert.strictEqual(
error.message,
'"export.type" must be one of [bind, djbdns, knot, NSD, maradns, powerdns, dynect]',
'"export.type" must be one of [bind, djbdns, knot, nsd, maradns, powerdns, dynect]',
)
assert.deepEqual(value, testCase)
})
Expand Down
2 changes: 1 addition & 1 deletion lib/test/nameserver.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"logdir": "/foo",
"datadir": "/bar",
"export": {
"type": "NSD",
"type": "nsd",
"interval": 0,
"serials": true,
"status": "last run:03-05 15:25<br>last cp :09-20 12:59"
Expand Down
7 changes: 2 additions & 5 deletions lib/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ const group = require('./group')

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

exports.username = Joi.string()
.min(3)
.max(50)
.pattern(new RegExp('^[a-zA-Z0-9 _.@-]+$', ''))
exports.username = Joi.string().min(3).max(50).pattern(new RegExp('^[a-zA-Z0-9 _.@-]+$', ''))

exports.password = JoiPassword.string()
.min(8)
Expand Down Expand Up @@ -41,7 +38,7 @@ exports.GET_req = Joi.object({
})

exports.GET_res = Joi.object({
user: exports.v3,
user: Joi.array().items(exports.v3),
group: Joi.object({
id: group.id,
name: group.name,
Expand Down
9 changes: 2 additions & 7 deletions lib/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,11 @@ describe('user', function () {
})

it('rejects too long', () => {
const username =
'abcdefghijklmopqrstuvwxyzabcdefghijklmopqrstuvwxyzabcdefghijklmopqrstuvwxyz'
const username = 'abcdefghijklmopqrstuvwxyzabcdefghijklmopqrstuvwxyzabcdefghijklmopqrstuvwxyz'

const { error, value } = schema.username.validate(username)

assert.ok(
/length must be less than or equal to 50 characters long/.test(
error.message,
),
)
assert.ok(/length must be less than or equal to 50 characters long/.test(error.message))
assert.deepEqual(value, username)
})

Expand Down
10 changes: 3 additions & 7 deletions lib/zone.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@ const shared = require('./shared')

exports.id = shared.uint32

exports.zone = Joi.string()
.min(3)
.max(255)
.domain({ allowFullyQualified: true, tlds: false })
.required()
exports.zone = Joi.string().min(3).max(255).domain({ allowFullyQualified: true, tlds: false })

exports.v3 = Joi.object({
id: exports.id,

gid: shared.uint32.required(),

zone: exports.zone,
zone: exports.zone.required(),

description: Joi.string().empty(''),

Expand All @@ -37,7 +33,7 @@ exports.v3 = Joi.object({

last_modified: Joi.date(),

last_publish: Joi.date().allow('', null),
last_publish: Joi.date().allow('0000-00-00 00:00:00', '', null),

deleted: Joi.boolean(),
})
Expand Down
5 changes: 1 addition & 4 deletions lib/zone.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ describe('zone', function () {
const { error, value } = schema.validate(testCase)
// if (error) console.error(error.message)

assert.strictEqual(
error.message,
'"zone" must contain a valid domain name',
)
assert.strictEqual(error?.message, '"zone" must contain a valid domain name')
assert.deepEqual(value, testCase)
})
}
Expand Down
Loading
Loading