Licence
MIT
Version
3.0.0
Deps
0
Vulns
0
Weekly
0
prompt-ajv
Prompts on the command line, validated with ajv (including ajv-formats keywords like email, date, uri, etc).
Works from both ESM and CommonJS.
// ESM
import prompt from 'prompt-ajv';
// CommonJS
const prompt = require('prompt-ajv');
const obj = await prompt({
name: { type: 'string', minLength: 2, required: true },
email: { type: 'string', format: 'email' },
pw: { type: 'string', secret: true },
size: { type: 'string', enum: ['xs', 'sm', 'lg'], default: 'sm' },
age: { type: 'integer', description: 'How old ru?', minimum: 0, maximum: 150 },
height: { type: 'number', description: 'Height in meters?', minimum: 0, maximum: 2.8, default: 1.8 },
});
console.log('obj:', obj);
Requires ajv and ajv-formats as peer dependencies:
npm i prompt-ajv ajv ajv-formats