Skip to content

Latest commit

 

History

History
131 lines (122 loc) · 7.54 KB

CHANGELOG.md

File metadata and controls

131 lines (122 loc) · 7.54 KB

Changelog

0.10.0 - 2020/01/07

  • is_decimal was added which validates if an object is an instance of decimal.Decimal.
  • is_number was modified to also consider instances of decimal.Decimal as numbers.

0.9.0 - 2020/01/07

  • Explanation objects now have a new attributes data which holds the data that was used to generate the explanation. For is_transformed and any of it's subclasses this will contain the transformed data. For classes like is_dict_where where other predicates are ran on parts of it's data it will replace these parts with the data on the explanation of that result.
  • Explanation objects now have a new method by_path that yields tuples of (path, subexplanation).
  • Explanation objects now have a more human readable result when you call repr.
  • Added is_blank and is_not_blank where value is considered blank if and only if not value holds.
  • Added is_pre for adding preconditions to predicates.
  • Using is_if with else_valid=False is now deprecated, in this case you should be using is_pre instead.
  • Changed if_match so that it now always uses search instead of match or fullmatch based on the full parameter to find the match. Behaviour of match and fullmatch can still be achieved by using the ^ and $ characters in your pattern.
  • Added the match_as_data option to is_match which when set to True will replace the explanation objects data attribute with the match object.
  • Added the is_decodable_json_where predicate which is a combination of is_decodable_where and is_json_where since these two are often used together.
  • Changed is_with so that if a non callable value is provided as a transform function it will be changed into a function that always returns this value.
  • Added is_with_context which is similar to is_with but operators on the current context instead of the data.
  • Changed Wrapper.wrap to return whatever it wrapped.
  • Added is_if.cases and is_when.cases as a shorthand for creating long if ... elif ... elif ... else structures without having to nest.
  • Added default_context to utils to easily specify default values for the predicate context.
  • Fixed utils.Wrapper incorrectly calling the wrapped predicate so that prerequisites were ignored.

0.8.0 - 2019/04/10

  • Refactored automatic predicate conversion to convert dict, tuple, and list instances to is_dict_where, is_tuple_where, and is_list_where respectively. For normal data this should be functionally equivalent but now you can nest other predicates inside this data.
  • Moved to_pred from is_eq to it's own module.
  • Simplify assert_valid into just an assertion function instead of a function generator.

0.7.1 - 2018/07/03

  • Refactored is_json_where, and is_json.
  • Added is_bytes, is_decodable_where, and is_decodable.

0.7.0 - 2018/03/01

  • Made assertions generated by assert_valid accept context arguments. These will then be forwarded to the underlying predicate. The assert_valid class itself also accepts a context argument in it's constructor that serves as a base context for the generated assertion.
  • Simplified is_tranformed and is_json_where a bit. This change is backwards incompatible.
  • Simplified utils.Wrapper to only wrap predicates. This way predicate testing using isinstance works for wrapper predicates as well.

0.6.0 - 2018/01/17

  • Wrapper class has been updated, it now doesn't just wrap function calls but also underlying attributes of the wrapped object. You now change what is wrapped by calling Wrapper.wrap(obj) instead of Wrapper.func = obj.
  • The dict predicates (is_dict_where, is_superdict_where, is_subdict_where) saw a small overhaul in how their explanation objects work. Instead of just giving an explanation that the keys are incorrect with details about which keys are extra and which are missing the explanation now gives explanation objects that state not_allowed or missing for these keys while also evaluating the keys that were present and could be evaluated.
  • is_iterable_where and it's subclasses (is_tuple_of, is_list_of) saw a small overhaul in how their explanation objects work. Instead of just giving an explanation that the length is incorrect the explanation now gives explanation objects that state overflow or missing for when data is too long or too short for the incorrect indexes while also evaluating the elements that were present and could be evaluated.
  • Transform methods were added to is_cond, with trans_cond and trans_pred you can alter the data before it gets entered into the conds or preds respectively. By default they just do nothing with the data.
  • is_with was added. Here you specify a dict of keys mapping to functions and a predicate that then stores the output of that function when the data gets entered for that key. Then in the following predicate you can use Get-objects to reference to that specific key. See the tests for a good example.
  • is_byte was added which checks for an int in range 0 to 255.

0.5.1 - 2018/01/12

  • Fix bug where is_dict_of didn't check if the value was a dict beforehand but only if it was iterable, thus leading to an exception being thrown when a value was evaluated that was iterable but not a dict.

0.5.0 - 2018/01/12

  • Introduction of this changelog.
  • is_dict_where now also accepts two dicts as arguments to indicate required and optional keys respectively.
  • The dict method on Explanation objects now has an extra keyword argument include_details=True to specify if you want it to put the details in the dict. Also if the details are some kind of structure made up out of dicts, lists and tuples it now traverses these structures to also convert all Explanation objects within them to dicts. (Small breaking change)
  • Wrapper utility class introduced, this just wraps a function that you can change at any moment by setting the func-attribute. Useful for when you want some kind of recursion in your predicate structure.
  • Predicate classes is_optional and is_nullable were added, given a predicate they become a predicate that holds when either the given predicate holds or the value is None. There are two versions because is_optional and is_nullable use is_none and is_null under the hood respectively.
  • is_cond now wraps its conds and preds with is_eq when they are not callable. Consistency :)
  • Almost complete rewrite without breaking any compatibility making all predicates be instances of a subclass of is_valid.base.Predicate instead of loose functions. This allows for some neat small things:
    • You can now use ~pred instead of is_not(pred), also is_not(is_not(pred)) just gives back pred now.
    • You can now use pred1 | pred2 instead of is_any(pred1, pred2), also is_any(pred1, is_any(pred2, pred3)) does the same as is_any(pred1, pred2, pred3) now.
    • You can now use pred1 & pred2 instead of is_all(pred1, pred2), also is_all(pred1, is_all(pred2, pred3)) does the same as is_all(pred1, pred2, pred3) now.
    • You can now use pred.explain(value) instead of pred(value, explain=True).

0.4.0 - 2017/11/26

  • Latest version before introduction of this changelog.