-
Notifications
You must be signed in to change notification settings - Fork 5
Modify privacy level of information within a Ruleset #246
Conversation
The function performs an internal check that a string is valid before attempting to parse it. There is no reasonable manner that it could be used publically. As such, it makes sense for it to be private.
This is a value used during the initial parsing of a ruleset_str. Rules can be added to Ruleset.rules separately to this updating, making them inconsistent. This likely means that it should be a variable rather than an attribute. The interim step is to make it private.
As noted in 52a0360 this can become inconsistent with Ruleset.rules. There should be a single attribute to maintain state. This ensures there is only one.
2 of the 3 potential errors had error messages. This adds the 3rd.
Information about Ruleset changes
Is there a use case for a user to validate a custom ruleset against the schema? How are we suggesting this is done? Check before using the json string to instantiate a ruleset? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above...
Try and instantiate a Ruleset from a string. If it instantiates all is good. Validating a string against the Ruleset Schema by calling a function on a random instance of the |
OR (if you want to do things raw) import json
import jsonschema
import iati.default
import iati.utilites
json.loads(ruleset_str, object_pairs_hook=iati.utilities.dict_raise_on_duplicates)
jsonschema.validate(self.ruleset, iati.default.ruleset_schema()) |
Fair enough - so... just testing this: I was expecting a
|
That looks like a bug! |
It's a bug with the Ruleset Schema. It would be expected that a Ruleset is in the format: {
"xpath": {
"dictionary": "of values"
}
} As it is, however, the Ruleset Schema does not specify that a Ruleset must be a dictionary of dictionaries. The following is therefore valid: {
"xpath": "some random string"
} This can be fixed by updating "patternProperties": {
".+": {
"type": "object",
"properties": {
[...]
}
}
} ie. add |
IATI/IATI-Rulesets#49 details a problem with the Ruleset Schema. This works around the problem.
A function and variable were public properties of a
Ruleset
when they didn't need to be.The variable was something that could become inconsistent with the
rules
attribute.The function acted on this variable in a manner that shouldn't ever need doing outside Ruleset initialisation.
This also documents the attribute that a Ruleset has.
This came about in the writing up of #245 to determine the information required to determine Ruleset equality.