Global validator
Global validator
jacob.steinberger
Posts: 86Questions: 18Answers: 1
in Editor
I'm attempting to create a global validator, like so:
let editor = new Editor( db, 'external' )
.validator( (editor, action, data) => {
console.log(data);
/*Object.keys( data.data ).forEach( function (key) {
var values = data.data[key];
console.log('key',key,'value',values);
});*/
return true;
} )
.fields(
From reviewing 'data', it looks like it only contains column data and not data as submitted by the client. After reviewing https://editor.datatables.net/manual/server, and https://editor.datatables.net/manual/nodejs/validation#Global-validators, it seems that it should contain a data object, but does not.
Am I missing something obvious?
This question has an accepted answers - jump to answer
Answers
A silly follow-up, while there doesn't appear to be a data definition at this level in the editor, it does exist for the field validator. If you need to do a global validator that takes submitted data into consideration, in NodeJS, req.body still contains all the submitted data.
I would indeed expect the third parameter given to
validator
to contain the submitted data for the row. This is the code for it.I've just tried modifying my demo to add:
And it outputs what is expected:
What version of Editor's Node JS libraries are you using?
Allan
User issue, you are absolutely correct.
Upon refresh, it looks like the validator is called on a select, which causes a different dump of data that I didn't look at close enough. This is probably where it's important to look at action!