Skip to content

Commit

Permalink
validate() is now protected
Browse files Browse the repository at this point in the history
  • Loading branch information
Rico Huijbers committed Jan 8, 2019
1 parent c7d4314 commit d2a656f
Show file tree
Hide file tree
Showing 18 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class PipelineDeployStackAction extends cdk.Construct {
});
}

public validate(): string[] {
protected validate(): string[] {
const result = super.validate();
const assets = this.stack.node.metadata.filter(md => md.type === cxapi.ASSET_METADATA);
if (assets.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export class RestApi extends cdk.Construct implements cdk.IDependable, IRestApi
/**
* Performs validation of the REST API.
*/
public validate() {
protected validate() {
if (this.methods.length === 0) {
return [ `The REST API doesn't contain any methods` ];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codebuild/lib/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ export class Project extends ProjectBase {
/**
* @override
*/
public validate(): string[] {
protected validate(): string[] {
const ret = new Array<string>();
if (this.source.type === SourceType.CodePipeline) {
if (this._secondarySources.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codepipeline-api/lib/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export abstract class Action extends cdk.Construct {
this.stage._internal._attachAction(this);
}

public validate(): string[] {
protected validate(): string[] {
return validation.validateArtifactBounds('input', this._actionInputArtifacts, this.artifactBounds.minInputs,
this.artifactBounds.maxInputs, this.category, this.provider)
.concat(validation.validateArtifactBounds('output', this._actionOutputArtifacts, this.artifactBounds.minOutputs,
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export class Pipeline extends cdk.Construct implements cpapi.IPipeline {
* https://docs.aws.amazon.com/codepipeline/latest/userguide/reference-pipeline-structure.html#pipeline-requirements
* @override
*/
public validate(): string[] {
protected validate(): string[] {
return [
...this.validateHasStages(),
...this.validateSourceActionLocations()
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codepipeline/lib/stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class Stage extends cdk.Construct implements cpapi.IStage, cpapi.IInterna
return this._actions.slice();
}

public validate(): string[] {
protected validate(): string[] {
return this.validateHasActions();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-dynamodb/lib/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ export class Table extends Construct {
*
* @returns an array of validation error message
*/
public validate(): string[] {
protected validate(): string[] {
const errors = new Array<string>();

if (!this.tablePartitionKey) {
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-ecs/lib/base/task-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export class TaskDefinition extends cdk.Construct {
/**
* Validate this task definition
*/
public validate(): string[] {
protected validate(): string[] {
const ret = super.validate();

if (isEc2Compatible(this.compatibility)) {
Expand Down Expand Up @@ -423,4 +423,4 @@ export interface ITaskDefinitionExtension {
* Apply the extension to the given TaskDefinition
*/
extend(taskDefinition: TaskDefinition): void;
}
}
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ecs/lib/ec2/ec2-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export class Ec2Service extends BaseService implements elb.ILoadBalancerTarget {
/**
* Validate this Ec2Service
*/
public validate(): string[] {
protected validate(): string[] {
const ret = super.validate();
if (!this.cluster.hasEc2Capacity) {
ret.push('Cluster for this service needs Ec2 capacity. Call addXxxCapacity() on the cluster.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class ApplicationListenerRule extends cdk.Construct implements cdk.IDepen
/**
* Validate the rule
*/
public validate() {
protected validate() {
if (this.actions.length === 0) {
return ['Listener rule needs at least one action'];
}
Expand Down Expand Up @@ -142,4 +142,4 @@ export class ApplicationListenerRule extends cdk.Construct implements cdk.IDepen
}
return ret;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export class ApplicationListener extends BaseListener implements IApplicationLis
/**
* Validate this listener.
*/
public validate(): string[] {
protected validate(): string[] {
const errors = super.validate();
if (this.protocol === ApplicationProtocol.Https && this.certificateArns.length === 0) {
errors.push('HTTPS Listener needs at least one certificate (call addCertificateArns)');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export abstract class BaseListener extends cdk.Construct implements cdk.IDependa
/**
* Validate this listener
*/
public validate(): string[] {
protected validate(): string[] {
if (this.defaultActions.length === 0) {
return ['Listener needs at least one default target group (call addTargetGroups)'];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-events/lib/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class EventRule extends Construct implements IEventRule {
mergeEventPattern(this.eventPattern, eventPattern);
}

public validate() {
protected validate() {
if (Object.keys(this.eventPattern).length === 0 && !this.scheduleExpression) {
return [ `Either 'eventPattern' or 'scheduleExpression' must be defined` ];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-iam/lib/policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class Policy extends Construct implements IDependable {
group.attachInlinePolicy(this);
}

public validate(): string[] {
protected validate(): string[] {
const result = new Array<string>();

// validate that the policy document is not empty
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-rds/lib/cluster-parameter-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class ClusterParameterGroup extends cdk.Construct implements IClusterPara
/**
* Validate this construct
*/
public validate(): string[] {
protected validate(): string[] {
if (Object.keys(this.parameters).length === 0) {
return ['At least one parameter required, call setParameter().'];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-stepfunctions/lib/states/parallel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class Parallel extends State implements INextable {
/**
* Validate this state
*/
public validate(): string[] {
protected validate(): string[] {
if (this.branches.length === 0) {
return ['Parallel must have at least one branch'];
}
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/cdk/test/core/test.construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,13 @@ export = {
'construct.validate() can be implemented to perform validation, construct.validateTree() will return all errors from the subtree (DFS)'(test: Test) {

class MyConstruct extends Construct {
public validate() {
protected validate() {
return [ 'my-error1', 'my-error2' ];
}
}

class YourConstruct extends Construct {
public validate() {
protected validate() {
return [ 'your-error1' ];
}
}
Expand All @@ -325,7 +325,7 @@ export = {
new YourConstruct(this, 'YourConstruct');
}

public validate() {
protected validate() {
return [ 'their-error' ];
}
}
Expand All @@ -338,7 +338,7 @@ export = {
new TheirConstruct(this, 'TheirConstruct');
}

public validate() {
protected validate() {
return [ 'stack-error' ];
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/cdk/test/test.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export = {
'app.synthesizeStack(stack) performs validation first (app.validateAll()) and if there are errors, it returns the errors'(test: Test) {

class Child extends Construct {
public validate() {
protected validate() {
return [ `Error from ${this.node.id}` ];
}
}
Expand Down

1 comment on commit d2a656f

@eladb
Copy link
Contributor

@eladb eladb commented on d2a656f Jan 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

Please sign in to comment.