@Override
    protected void check(Shape shape, LengthTrait trait, ArrayNode node, Context context, Emitter emitter) {
        trait.getMin().ifPresent(min -> {
            if (node.size() < min) {
                emitter.accept(node,
                        String.format(
                                "Value provided for `%s` must have at least %d elements, but the provided value only "
                                        + "has %d elements",
                                shape.getId(),
                                min,
                                node.size()));
            }
        });

        trait.getMax().ifPresent(max -> {
            if (node.size() > max) {
                emitter.accept(node,
                        String.format(
                                "Value provided for `%s` must have no more than %d elements, but the provided value "
                                        + "has %d elements",
                                shape.getId(),
                                max,
                                node.size()));
            }
        });
    }
Validates the length trait on both list and set shapes or members that
target them.
smithy-model/src/main/java/software/amazon/smithy/model/validation/node/CollectionLengthPlugin.java