Ejemplo n.º 1
0
// ReadRegexp prints the prompt waiting to get a string that matches with a regular expression.
func (q *Question) ReadRegexp(options, pattern string) (string, error) {
	valida := validate.NewRegexp(q.mod, options, pattern)
	if q.defValue != nil {
		valida.SetDefault(q.defValue)
		q.defString = defaultToPrint(q.defValue)
	}

	value, err := q.read(q.newLine(), valida)
	q.clean()
	return value.(string), err
}
Ejemplo n.º 2
0
// NewRegexp sets a regular expression "re" with a name to be identified.
func (q *Question) NewRegexp(name, re string) *Question {
	q.val = validate.NewRegexp(q.mod, name, re)
	return q
}