Package io.inversion
Class Request.Validation
java.lang.Object
io.inversion.Request.Validation
- Enclosing class:
Request
Utility designed to make it easy to validate request properties or request body
json values while you are retrieving them.
Required (Not Null)
To ensure a field is not null, use the required() method:
- String nameFirst = request.validate("nameFirst", "A first name is required").required().asString();
Comparison
To validate a number is greater than 5, then return its value:
- int myParam = request.validate("myParamName", "optional_custom_error_message").gt(5).asInt();
-
Constructor Summary
ConstructorsConstructorDescriptionValidation(Request req, String propOrPath, String customErrorMessage) Validation(Response res, String jsonPath, String customErrorMessage) -
Method Summary
Modifier and TypeMethodDescriptionasArray()booleandoubleasDouble()intasInt()asNode()asString()protected intprotected voidThrows an ApiException 400 using customErrorMessage or defaultErrorMessagelength(int max) length(int min, int max) If there are anychildPropsthey must exist on the JSNode found atpathOrProp.value()
-
Constructor Details
-
Validation
-
Validation
-
-
Method Details
-
required
If there are anychildPropsthey must exist on the JSNode found atpathOrProp. IfchildPropsare null/empty thenpathOrPropmust not be null.- Parameters:
childProps- the child properties to check for- Returns:
- this
- Throws:
ApiException- 400 if the referenced validation is null.
-
matches
-
in
-
out
-
compareTo
-
gt
-
ge
-
lt
-
le
-
eq
-
ne
-
length
-
length
-
minMax
-
max
-
min
-
value
-
asNode
-
asArray
-
asString
-
asInt
public int asInt() -
asDouble
public double asDouble() -
asBoolean
public boolean asBoolean() -
fail
Throws an ApiException 400 using customErrorMessage or defaultErrorMessage- Parameters:
defaultErrorMessage- the default error message- Throws:
ApiException- always
-