Kevin
02/24/2022, 8:08 PMNbtwist
02/24/2022, 8:13 PMKevin
02/24/2022, 8:21 PMKevin
02/24/2022, 8:21 PMNbtwist
02/24/2022, 8:21 PMKevin
02/24/2022, 8:21 PMKevin
02/24/2022, 8:22 PMKevin
02/24/2022, 8:22 PMNbtwist
02/24/2022, 8:24 PMvar x = Object.keys(context);
if (x.indexOf('keyname') != -1) {
// do something
}
Nbtwist
02/24/2022, 8:24 PMKevin
02/24/2022, 8:46 PM{
"Order": {
"ID": 234,
"items": [
{
"sku": "3454JJ",
"quantity": 1
},
{
"sku": "3454JJ",
"quantity": 1
}
]
}
}
Nbtwist
02/24/2022, 8:47 PMRichard Tanner
02/24/2022, 9:34 PMKevin
02/24/2022, 10:17 PMKevin
02/24/2022, 10:27 PMRichard Tanner
02/24/2022, 10:27 PMKevin
02/24/2022, 10:28 PMRichard Tanner
02/24/2022, 10:29 PMnew Ajv({ logger: false });
Richard Tanner
02/24/2022, 10:31 PMKevin
02/24/2022, 10:50 PMKevin
02/24/2022, 11:31 PMKevin
02/24/2022, 11:31 PMKevin
02/25/2022, 12:14 AMKevin
02/25/2022, 12:40 AMKevin
02/28/2022, 6:43 PMRichard Tanner
02/28/2022, 7:00 PM/**
* @NApiVersion 2.1
* @NScriptType Suitelet
*/
define(['SuiteScripts/Test/ajv7'],
(Ajv) => {
/**
* Defines the Suitelet script trigger point.
* @param {Object} scriptContext
* @param {ServerRequest} scriptContext.request - Incoming request
* @param {ServerResponse} scriptContext.response - Suitelet response
* @since 2015.2
*/
const onRequest = (scriptContext) => {
const ajv=new Ajv({allErrors: true,logger: false});
const schema = {
type: "object",
properties: {
foo: {type: "integer"},
bar: {type: "string"}
},
required: ["foo"],
additionalProperties: false
}
const validate = ajv.compile(schema);
const data = {
foo: 1,
bar: "abc"
}
const valid = validate(data);
scriptContext.response.write(JSON.stringify(valid));
}
return {onRequest}
});
Kevin
02/28/2022, 8:04 PMKevin
02/28/2022, 8:10 PMKevin
02/28/2022, 8:10 PMKevin
02/28/2022, 8:10 PMRichard Tanner
02/28/2022, 9:32 PMKevin
02/28/2022, 10:07 PMKevin
02/28/2022, 10:07 PMKevin
03/01/2022, 4:29 PM