Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contains - can I specify multiple values? #63

Open
charlie-ablett opened this issue May 18, 2016 · 3 comments
Open

Contains - can I specify multiple values? #63

charlie-ablett opened this issue May 18, 2016 · 3 comments

Comments

@charlie-ablett
Copy link

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?

@goowikns
Copy link
Contributor

+1 Would love to know too

@dudeinthemirror
Copy link

+1 please.

@mzalazar
Copy link

mzalazar commented Nov 29, 2017

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']
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants