Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark node validation visitors internal #375

Merged
merged 1 commit into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import software.amazon.smithy.model.validation.node.TimestampValidationStrategy;
import software.amazon.smithy.utils.ListUtils;
import software.amazon.smithy.utils.SmithyBuilder;
import software.amazon.smithy.utils.SmithyUnstableApi;

/**
* Validates {@link Node} values provided for {@link Shape} definitions.
Expand Down Expand Up @@ -465,6 +466,7 @@ public Builder eventShapeId(ShapeId eventShapeId) {
* @param timestampValidationStrategy Timestamp validation strategy.
* @return Returns the builder.
*/
@SmithyUnstableApi
public Builder timestampValidationStrategy(TimestampValidationStrategy timestampValidationStrategy) {
this.timestampValidationStrategy = timestampValidationStrategy;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
import software.amazon.smithy.model.shapes.BlobShape;
import software.amazon.smithy.model.shapes.Shape;
import software.amazon.smithy.model.traits.LengthTrait;
import software.amazon.smithy.utils.SmithyInternalApi;

/**
* Validates length trait on blob shapes and members that target blob shapes.
*/
@SmithyInternalApi
public final class BlobLengthPlugin extends MemberAndShapeTraitPlugin<BlobShape, StringNode, LengthTrait> {
public BlobLengthPlugin() {
super(BlobShape.class, StringNode.class, LengthTrait.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
import software.amazon.smithy.model.shapes.CollectionShape;
import software.amazon.smithy.model.shapes.Shape;
import software.amazon.smithy.model.traits.LengthTrait;
import software.amazon.smithy.utils.SmithyInternalApi;

/**
* Validates the length trait on both list and set shapes or members that
* target them.
*/
@SmithyInternalApi
public class CollectionLengthPlugin extends MemberAndShapeTraitPlugin<CollectionShape, ArrayNode, LengthTrait> {
public CollectionLengthPlugin() {
super(CollectionShape.class, ArrayNode.class, LengthTrait.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
import software.amazon.smithy.model.shapes.StringShape;
import software.amazon.smithy.model.traits.IdRefTrait;
import software.amazon.smithy.utils.ListUtils;
import software.amazon.smithy.utils.SmithyInternalApi;

/**
* Validates that the value contained in a string shape is a valid shape ID
* and that the shape ID targets a shape that is in the set of shapes
* matching the selector.
*/
@SmithyInternalApi
public final class IdRefPlugin extends MemberAndShapeTraitPlugin<StringShape, StringNode, IdRefTrait> {

public IdRefPlugin() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import software.amazon.smithy.model.shapes.MapShape;
import software.amazon.smithy.model.shapes.Shape;
import software.amazon.smithy.model.traits.LengthTrait;
import software.amazon.smithy.utils.SmithyInternalApi;

/**
* Validates the length trait on map shapes or members that target them.
*/
@SmithyInternalApi
public final class MapLengthPlugin extends MemberAndShapeTraitPlugin<MapShape, ObjectNode, LengthTrait> {
public MapLengthPlugin() {
super(MapShape.class, ObjectNode.class, LengthTrait.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.node.Node;
import software.amazon.smithy.model.shapes.Shape;
import software.amazon.smithy.utils.SmithyInternalApi;

/**
* Applies pluggable validation when validating {@link Node} values against
* the schema of a {@link Shape} (e.g., when validating that the values
* provided for a trait in the model are valid for the shape of the trait).
*/
@SmithyInternalApi
public interface NodeValidatorPlugin {
/**
* Applies the plugin to the given shape, node value, and model.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import software.amazon.smithy.model.shapes.StringShape;
import software.amazon.smithy.model.traits.PatternTrait;
import software.amazon.smithy.utils.ListUtils;
import software.amazon.smithy.utils.SmithyInternalApi;

/**
* Validates the pattern trait on string shapes or members that target them.
*/
@SmithyInternalApi
public final class PatternTraitPlugin extends MemberAndShapeTraitPlugin<StringShape, StringNode, PatternTrait> {
public PatternTraitPlugin() {
super(StringShape.class, StringNode.class, PatternTrait.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
import software.amazon.smithy.model.shapes.NumberShape;
import software.amazon.smithy.model.shapes.Shape;
import software.amazon.smithy.model.traits.RangeTrait;
import software.amazon.smithy.utils.SmithyInternalApi;

/**
* Validates the range trait on number shapes or members that target them.
*/
@SmithyInternalApi
public final class RangeTraitPlugin extends MemberAndShapeTraitPlugin<NumberShape, NumberNode, RangeTrait> {
public RangeTraitPlugin() {
super(NumberShape.class, NumberNode.class, RangeTrait.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import software.amazon.smithy.model.shapes.StringShape;
import software.amazon.smithy.model.traits.EnumTrait;
import software.amazon.smithy.model.validation.ValidationUtils;
import software.amazon.smithy.utils.SmithyInternalApi;

/**
* Validates the enum trait on string shapes.
*/
@SmithyInternalApi
public final class StringEnumPlugin extends FilteredPlugin<StringShape, StringNode> {
public StringEnumPlugin() {
super(StringShape.class, StringNode.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import software.amazon.smithy.model.shapes.Shape;
import software.amazon.smithy.model.shapes.StringShape;
import software.amazon.smithy.model.traits.LengthTrait;
import software.amazon.smithy.utils.SmithyInternalApi;

/**
* Validates the length trait on string shapes or members that target them.
*/
@SmithyInternalApi
public final class StringLengthPlugin extends MemberAndShapeTraitPlugin<StringShape, StringNode, LengthTrait> {
public StringLengthPlugin() {
super(StringShape.class, StringNode.class, LengthTrait.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
import software.amazon.smithy.model.shapes.TimestampShape;
import software.amazon.smithy.model.traits.TimestampFormatTrait;
import software.amazon.smithy.utils.ListUtils;
import software.amazon.smithy.utils.SmithyInternalApi;

/**
* Validates that timestamp shapes contain values that are compatible with their
* timestampFormat traits or contain values that are numbers or an RFC 3339
* date-time production.
*/
@SmithyInternalApi
public final class TimestampFormatPlugin implements NodeValidatorPlugin {
private static final DateTimeFormatter HTTP_DATE = DateTimeFormatter.RFC_1123_DATE_TIME;
private static final DateTimeFormatter DATE_TIME_Z = DateTimeFormatter.ISO_INSTANT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import software.amazon.smithy.model.shapes.MemberShape;
import software.amazon.smithy.model.shapes.Shape;
import software.amazon.smithy.utils.ListUtils;
import software.amazon.smithy.utils.SmithyInternalApi;

/**
* Defines how timestamps are validated.
*/
@SmithyInternalApi
public enum TimestampValidationStrategy implements NodeValidatorPlugin {
/**
* Validates timestamps by requiring that the value uses matches the
Expand Down