Dml
A data modeling language (for node and the browser)
Install / Use
/learn @voltraco/DmlREADME
SYNOPSIS
A data modeling language reference implementation. See dml.sh
BUILD
USAGE
sample.model
Define a model using the data modeling language syntax
// An example data model
Date created
Number id
String name
require // this is a comment
gt 2 "Must be greater than 2 characters"
lte 256 "Must be less than or equal to 256 characters"
String bio "A bio must be a string"
lte 140 "A bio must fit into a tweet"
Boolean accountType
index.js
Compiling a model returns a function that will validate data.
const Models = require('node-dml')
let model = Models.compile(fs.readFileSync('sample.model', 'utf8'))
let result = model({
id: 1337,
created: new Date(),
name: 'Glen Danzig',
accountType: 'awesome'
})
output
The result will be an object that contains the final data, as well as a
length property which indicates how many rules were violated, and a rules
property containing information about the rules that were violated.
{
data: {
id: 1337,
created: '2016-10-02T13:56:44.931Z',
name: 'Glen Danzig',
accountType: 'awesome'
},
length: 1,
rules: {
accountType: [{
validator: 'type',
message: 'Expected type [Boolean] but got type [String]'
}]
}
}
Related Skills
node-connect
338.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
338.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.4kCommit, push, and open a PR
