flatiron / prompt

a beautiful command-line prompt for node.js

Home Page:http://github.com/flatiron/prompt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shouldn't the before() callback modify the value that is actually going to be validated?

diegovilar opened this issue · comments

If you define a before(value) => newValue callback for a property, the transformed input is not the one that is going to be validated. The validation will occur against the original input.

Shouldn't the validation function be passed the transformed input instead?

My use case is that I'm asking for a version string, which will ultimately be validated against a Semantic Version pattern, but I want to be flexible enough to allow the user to input simple versions (i.e. 1 or 1.1). My before() transformation function handles such cases (and only such cases) and transforms the input into valid semver values (i.e. 1.0.0 and 1.1.0). Any other value is returned as-is by the transformation function to be validated against pattern. #