validateOptions - Methods - Evaluation Options Editor API

Evaluation Options Editor API Methods

validateOptions()

Checks whether the specified evaluation options match the evaluation options schema.

You would want to use this method so that you can check options before you load them into the editor or save them to your database.

Examples

// Validate options that contain a marking style that is not allowed, and log the result
const validateResult = await editor.validateOptions({
    grading: {
        marking_style: 'strict'
    }
});
console.log(validateResult);
/* Example output:
{
    isValid: false,
    errors: [
        {
            location: 'Grading > Marking style',
            message: 'must be equal to one of the allowed values'
        }
    ]
}
*/

Arguments

  • options object

    The evaluation options JSON object to validate.

  • settings object

    Controls optional settings for how the options are validated.

    The following properties are supported.

    • strict boolean

      Controls whether the options are validated against the evaluation options schema.

      When set to false, the method does not validate the options and always resolves with isValid set to true.

      Default: true

Return value

Type Promise

Resolves with an object containing the following properties:

  • isValid boolean

    Indicates whether the options are valid.

  • errors array[object]

    The validation errors. Present only when the options are not valid.

    Each error has a location string that identifies the option and a message string that describes the problem.

Related articles

Was this article helpful?

Did you arrive here by accident? If so, learn more about Learnosity.