const validator = new JsonSchema.Validator(schema);
Assert.deepEqual(
JsonSchema.validate({ id: 123 }, schema),
{ valid: true, errors: [] }, "Validation of basic schemas with validate()"
);
Assert.deepEqual(
validator.validate({ id: 123 }, schema),
{ valid: true, errors: [] }, "Validation of basic schemas with Validator"
);
Assert.ok(
!JsonSchema.validate({}, schema).valid, "Validation of basic schemas with validate()"
); Assert.ok(
!validator.validate({}).valid, "Validation of basic schemas with Validator"
);
});
Assert.equal(
Services.urlFormatter.formatURL(obj),
obj, "BOGUS is an invalid variable for the URL formatter service"
);
Assert.ok(
!JsonSchema.validate(obj, { type: "string", format: "uri" }).valid, "A moz-url-format string does not validate as a URI"
);
Assert.deepEqual(
JsonSchema.validate(obj, schema),
{
valid: false,
errors: [
{
instanceLocation: "#",
keyword: "format",
keywordLocation: "#/format",
error: `String does not match format "moz-url-format".`,
},
],
}, "Substitution of an invalid variable does not validate"
);
}
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.