Closed raja-i4 closed 8 years ago
You've included the library validator.js
, this library name is called validate.js
.
like presence, length, type, format, etc. for length: minimum, maximum, etc
I would like to see complete list of these. I mean complete schema definition.
These is no place where they are all shown together, but you have the list of all the constraints and if you click on a constraint you can read about all the options.
https://validatejs.org/#constraints . this page has minimal list.
If i look at source code, i got the following: presence, length, numericality, datetime, date, format, inclusion, exclusion, email, url, equality, pattern.
Pls let me know if i miss anything.
ok, thanks. It has the same. :)
Hi,
I’m just reposting on the same as I couldn’t open a browser to create a new case.
My concern here is : I would like to find out excess data in “data” to be evaluated. For instance, My constraints = { “a” : { “presence”: true}, “b” : { “presence”: true}, “c” : { “presence”: true} }
My data:
{ “a” : 1, “b” : 2, “c” : 3, “d” : 4 }
My data has excess data “d”, do you have logic inplace to determine such things with any options. (without any options, it is unable to find out excess data)
Here my concern mainly is strict validation: data must match the constraints. No more or no less data should be there.
Thanks, Rajashekhar
No, there is currently no way to validate that. But the cleanAttributes function might help.
cleanAttributes should have named as retainAttributes, and cleanAttributes should remove the given attributes.
From: Nicklas Ansman Giertz [mailto:notifications@github.com] Sent: Tuesday, April 26, 2016 1:02 PM To: ansman/validate.js validate.js@noreply.github.com Cc: Rajashekhar G rajashekhar.g@intellifour.com; Author author@noreply.github.com Subject: Re: [ansman/validate.js] Examples are not working properly (#120)
No, there is currently no way to validate that. But the cleanAttributeshttp://validatejs.org/#utilities-clean-attributes function might help.
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHubhttps://github.com/ansman/validate.js/issues/120#issuecomment-214653903
validate.extend(validate.validators.datetime, { // The value is guaranteed not to be null or undefined but otherwise it // could be anything. parse: function(value, options) { return +moment.utc(value); }, // Input is a unix timestamp format: function(value, options) { var format = options.dateOnly ? "YYYY-MM-DD" : "YYYY-MM-DD hh:mm:ss"; return moment.utc(value).format(format); } });
validate({departure: "foobar"}, {departure: {datetime: true}}); ReferenceError: moment is not defined at Function.validate.extend.parse (repl:5:9) at Function.validate.validators.datetime.v.extend.parse (d:\workspace\nodejs\test\node_modules\validate.js\validate.js:881:20) at Function.v.extend.runValidations (d:\workspace\nodejs\test\node_modules\validate.js\validate.js:133:30) at validate (d:\workspace\nodejs\test\node_modules\validate.js\validate.js:25:21) at repl:1:1 at REPLServer.defaultEval (repl.js:262:27) at bound (domain.js:287:14) at REPLServer.runBound as eval at REPLServer.
(repl.js:431:12) at emitOne (events.js:82:20)
From: Nicklas Ansman Giertz [mailto:notifications@github.com] Sent: Tuesday, April 26, 2016 1:02 PM To: ansman/validate.js validate.js@noreply.github.com Cc: Rajashekhar G rajashekhar.g@intellifour.com; Author author@noreply.github.com Subject: Re: [ansman/validate.js] Examples are not working properly (#120)
No, there is currently no way to validate that. But the cleanAttributeshttp://validatejs.org/#utilities-clean-attributes function might help.
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHubhttps://github.com/ansman/validate.js/issues/120#issuecomment-214653903
Please read the documentation: http://validatejs.org/#validators-datetime
Hi,
I'm facing problem while running the given examples in node js environment.
this is how i'm using it.
While it is building constraints from the given config, it is failing by saying 'Should give a valid mapping object to Constraint'. It is failing while processing "presence" : true attribute.
Please find the screenshot below:
Please let me know how to resolve this problem.