Open charlie-ablett opened 8 years ago
+1 Would love to know too
+1 please.
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']
});
We're using an enum in the db to restrict a
varchar
field to a set of values (required
oroptional
- 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?