Model transform(ModelTransformer transformer, Model model) {
        Set<Shape> invalidDefaults = new HashSet<>();
        Set<Shape> updates = new HashSet<>();

        // First collect invalid shapes. Members with invalid defaults either need to remove the default or
        // set the default to null if their target shape's default remains intact but the member is invalid.
        for (Shape shape : model.getShapesWithTrait(DefaultTrait.class)) {
            shape.getMemberTrait(model, RangeTrait.class).ifPresent(rangeTrait -> {
                DefaultTrait defaultTrait = shape.expectTrait(DefaultTrait.class);
                if (defaultTrait.toNode().isNumberNode()) {
                    defaultTrait.toNode().expectNumberNode().asBigDecimal().ifPresent(value -> {
                        if (rangeTrait.getMin().filter(min -> value.compareTo(min) < 0).isPresent()
                                || rangeTrait.getMin().filter(max -> value.compareTo(max) > 0).isPresent()) {
                            invalidDefaults.add(shape);
                        }
                    });
                }
            });
        }

        for (Shape shape : invalidDefaults) {
            updates.add(modify(shape, model, invalidDefaults));
        }

        return transformer.replaceShapes(model, updates);
    }
Removes default values from shapes where the default value is incompatible with
the constraint traits of the shape.
smithy-model/src/main/java/software/amazon/smithy/model/transform/RemoveInvalidDefaults.java