-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
231 additions
and
37 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
codegen/projections/high_score_service/lib/high_score_service/config.rb
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
30 changes: 30 additions & 0 deletions
30
...by-codegen/src/main/java/software/amazon/smithy/ruby/codegen/config/ConfigConstraint.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,30 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.smithy.ruby.codegen.config; | ||
|
||
/** | ||
* Represents the config value constraints for ClientConfig. | ||
*/ | ||
|
||
public interface ConfigConstraint { | ||
/** | ||
* Render the constraint validator for the config value. | ||
* | ||
* @param configName the name of the config. | ||
* @return the string to be rendered into Ruby code. | ||
*/ | ||
String render(String configName); | ||
} |
42 changes: 42 additions & 0 deletions
42
...uby-codegen/src/main/java/software/amazon/smithy/ruby/codegen/config/RangeConstraint.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,42 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.smithy.ruby.codegen.config; | ||
|
||
/** | ||
* Range Constraint for config value. | ||
*/ | ||
public class RangeConstraint implements ConfigConstraint { | ||
|
||
private final long minValue; | ||
private final long maxValue; | ||
|
||
/** | ||
* @param minValue the minimum value | ||
* @param maxValue the maximum value | ||
*/ | ||
public RangeConstraint(long minValue, long maxValue) { | ||
this.maxValue = maxValue; | ||
this.minValue = minValue; | ||
} | ||
|
||
@Override | ||
public String render(String configName) { | ||
return String.format( | ||
"Hearth::Validator.validate_range!(%s, min: %d, max: %d, context: 'config[:%s]')", | ||
configName, minValue, maxValue, configName); | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
...ruby-codegen/src/main/java/software/amazon/smithy/ruby/codegen/config/TypeConstraint.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,42 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.smithy.ruby.codegen.config; | ||
|
||
/** | ||
* Type Constraint for config value. | ||
*/ | ||
public class TypeConstraint implements ConfigConstraint { | ||
|
||
private final String type; | ||
|
||
/** | ||
* @param type ruby type for the config. Used for validation, must be a valid Ruby class or Boolean. | ||
*/ | ||
public TypeConstraint(String type) { | ||
if (type.equals("Boolean")) { | ||
this.type = "TrueClass, FalseClass"; | ||
} else { | ||
this.type = type; | ||
} | ||
} | ||
|
||
@Override | ||
public String render(String configName) { | ||
return String.format( | ||
"Hearth::Validator.validate_types!(%s, %s, context: 'config[:%s]')", | ||
configName, type, configName); | ||
} | ||
} |
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
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
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.