
com.zuunr.json.schema.validation.node.string.MaxLengthNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of json Show documentation
Show all versions of json Show documentation
Immutable JSON representation in Java
package com.zuunr.json.schema.validation.node.string;
import com.zuunr.json.JsonValue;
import com.zuunr.json.schema.JsonSchema;
import com.zuunr.json.schema.Keywords;
import com.zuunr.json.schema.validation.ValidationContext;
import com.zuunr.json.schema.validation.node.KeywordNode;
/**
* @author Niklas Eldberger
*/
public class MaxLengthNode extends KeywordNode {
public MaxLengthNode(JsonValue instance, JsonSchema schema, int keywordIndex, ValidationContext validationContext, JsonValue rootInstance) {
super(instance, schema, keywordIndex, validationContext, rootInstance);
}
@Override
protected Boolean calculateValid() {
JsonValue maxLengthJsonValue = schema.getKeyword(Keywords.MAX_LENGTH);
JsonValue data = dataKeywordValue(maxLengthJsonValue);
if (data != null) {
maxLengthJsonValue = data;
}
Long maxLength = maxLengthJsonValue.getLong();
return instance.getString().length() <= maxLength;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy