-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced new validators and validating control flow improved
- Loading branch information
Showing
16 changed files
with
284 additions
and
171 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
vaunt-validator/src/main/java/com/hltech/vaunt/validator/BooleanSchemaValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.hltech.vaunt.validator; | ||
|
||
import com.fasterxml.jackson.module.jsonSchema.JsonSchema; | ||
import com.fasterxml.jackson.module.jsonSchema.types.BooleanSchema; | ||
|
||
import java.util.List; | ||
|
||
public class BooleanSchemaValidator extends ValueTypeSchemaValidator { | ||
|
||
@Override | ||
public List<String> validate(JsonSchema consumerSchema, JsonSchema providerSchema) { | ||
return super.validate(consumerSchema, providerSchema); | ||
} | ||
|
||
@Override | ||
public Class<?> supportsSchemaType() { | ||
return BooleanSchema.class; | ||
} | ||
} |
32 changes: 13 additions & 19 deletions
32
vaunt-validator/src/main/java/com/hltech/vaunt/validator/ContainerTypeSchemaValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
vaunt-validator/src/main/java/com/hltech/vaunt/validator/IntegerSchemaValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.hltech.vaunt.validator; | ||
|
||
import com.fasterxml.jackson.module.jsonSchema.JsonSchema; | ||
import com.fasterxml.jackson.module.jsonSchema.types.IntegerSchema; | ||
|
||
import java.util.List; | ||
|
||
public class IntegerSchemaValidator extends NumberSchemaValidator { | ||
|
||
@Override | ||
public List<String> validate(JsonSchema consumerSchema, JsonSchema providerSchema) { | ||
List<String> errors = super.validate(consumerSchema, providerSchema); | ||
|
||
IntegerSchema consumerIntegerSchema = consumerSchema.asIntegerSchema(); | ||
IntegerSchema providerIntegerSchema = providerSchema.asIntegerSchema(); | ||
|
||
if (!equals(consumerIntegerSchema.getDivisibleBy(), providerIntegerSchema.getDivisibleBy())) { | ||
errors.add(String.format(ERROR_FORMAT, | ||
consumerIntegerSchema.getId(), | ||
"divisibleBy", | ||
consumerIntegerSchema.getDivisibleBy(), | ||
providerIntegerSchema.getDivisibleBy())); | ||
} | ||
|
||
return errors; | ||
} | ||
|
||
@Override | ||
public Class<?> supportsSchemaType() { | ||
return IntegerSchema.class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
vaunt-validator/src/main/java/com/hltech/vaunt/validator/NumberSchemaValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.hltech.vaunt.validator; | ||
|
||
import com.fasterxml.jackson.module.jsonSchema.JsonSchema; | ||
import com.fasterxml.jackson.module.jsonSchema.types.NumberSchema; | ||
|
||
import java.util.List; | ||
|
||
public class NumberSchemaValidator extends ValueTypeSchemaValidator { | ||
|
||
@Override | ||
public List<String> validate(JsonSchema consumerSchema, JsonSchema providerSchema) { | ||
List<String> errors = super.validate(consumerSchema, providerSchema); | ||
|
||
NumberSchema consumerNumberSchema = consumerSchema.asNumberSchema(); | ||
NumberSchema providerNumberSchema = providerSchema.asNumberSchema(); | ||
|
||
if (!equals(consumerNumberSchema.getExclusiveMaximum(), providerNumberSchema.getExclusiveMaximum())) { | ||
errors.add(String.format(ERROR_FORMAT, | ||
consumerNumberSchema.getId(), | ||
"exclusiveMaximum", | ||
consumerNumberSchema.getExclusiveMaximum(), | ||
providerNumberSchema.getExclusiveMaximum())); | ||
} | ||
|
||
if (!equals(consumerNumberSchema.getExclusiveMinimum(), providerNumberSchema.getExclusiveMinimum())) { | ||
errors.add(String.format(ERROR_FORMAT, | ||
consumerNumberSchema.getId(), | ||
"exclusiveMinimum", | ||
consumerNumberSchema.getExclusiveMinimum(), | ||
providerNumberSchema.getExclusiveMinimum())); | ||
} | ||
|
||
if (!equals(consumerNumberSchema.getMaximum(), providerNumberSchema.getMaximum())) { | ||
errors.add(String.format(ERROR_FORMAT, | ||
consumerNumberSchema.getId(), | ||
"maximum", | ||
consumerNumberSchema.getMaximum(), | ||
providerNumberSchema.getMaximum())); | ||
} | ||
|
||
if (!equals(consumerNumberSchema.getMinimum(), providerNumberSchema.getMinimum())) { | ||
errors.add(String.format(ERROR_FORMAT, | ||
consumerNumberSchema.getId(), | ||
"minimum", | ||
consumerNumberSchema.getMinimum(), | ||
providerNumberSchema.getMinimum())); | ||
} | ||
|
||
if (!equals(consumerNumberSchema.getMultipleOf(), providerNumberSchema.getMultipleOf())) { | ||
errors.add(String.format(ERROR_FORMAT, | ||
consumerNumberSchema.getId(), | ||
"multipleOf", | ||
consumerNumberSchema.getMultipleOf(), | ||
providerNumberSchema.getMultipleOf())); | ||
} | ||
|
||
return errors; | ||
} | ||
|
||
@Override | ||
public Class<?> supportsSchemaType() { | ||
return NumberSchema.class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.