-
Notifications
You must be signed in to change notification settings - Fork 0
Implementing your own rules
Esta Nagy edited this page Jul 1, 2020
·
3 revisions
Each rule absolutely needs two parameters (alongside the name of the rule) and can have additional parameters on top of those at the discretion of the implementation.
Name | Type | Meaning |
---|---|---|
order |
Integer |
The order of the rule in the rule list. |
jsonPath |
com.jayway.jsonpath.JsonPath |
The path the rule should apply to. |
Additional parameters are either stored in the param
map of the RawJsonRule
or can be using one of the supported parameter
types as described here.
The interface all the Rules must implement is called JsonRule.
If you can't seem to find the rule that fits your needs, you can always implement your own rule by doing the simple steps below.
- Create a class implementing the
JsonRule
interface or feel free to extend AbstractJsonRule for a bit of convenience. - Define a constructor with using only RawJsonRule and the supported parameter if needed.
- Annotate it with @NamedRule adding a unique name for your rule.
- In your constructor, figure out how to convert the input parameters you need.
- Implement the abstract methods coming form the interface/super class.
- Register your rule using JsonRuleRegistry#registerRuleClass(Class)
- Add your rule to the #/definitions/ruleTypes/definitions node of our JSON Schema
- Make sure to add it to the generic #/definitions/ruleTypes/definitions/anyRule type as well
- Yippee-Ki-Yay you made it! You can start using your new rule.