checkit icon indicating copy to clipboard operation
checkit copied to clipboard

Contains - can I specify multiple values?

Open charlie-ablett opened this issue 8 years ago • 3 comments

We're using an enum in the db to restrict a varchar field to a set of values (required or optional - which of course is confusing in itself! :-p)

Is this kind of validation possible?

necessity: [ 'required', { rule: 'contains', params: ['required', 'optional'] } ]

This only allows the first value... is this a bug or is this intentional? Is it possible to allow multiple valid values to be enumerated?

charlie-ablett avatar May 18 '16 19:05 charlie-ablett

+1 Would love to know too

goowikns avatar Jun 17 '16 12:06 goowikns

+1 please.

dudeinthemirror avatar Jul 15 '16 18:07 dudeinthemirror

This is the code i use (some kind of "ENUM") for testing for 2 values, "final" and "test":

// Extend Checkit object
Checkit.Validator.prototype.types = function (val) {
	if (typeof val === 'string' && (val.toLowerCase() === 'test' || val.toLowerCase() === 'final')) {
		return true;
	} else {
		return false;
	}
}

USE:

new Checkit({
     my_param : ['types']
});

mzalazar avatar Nov 29 '17 08:11 mzalazar