This file contains hidden or 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
| fun EditText.afterTextChanged(afterTextChanged: (String) -> Unit) { | |
| this.addTextChangedListener(object: TextWatcher { | |
| override fun afterTextChanged(s: Editable?) { | |
| afterTextChanged.invoke(s.toString()) | |
| } | |
| override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { } | |
| override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { } | |
| }) |
This file contains hidden or 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
| fun EditText.validate(validator: (String) -> Boolean, message: String) { | |
| this.afterTextChanged { | |
| this.error = if (validator(it)) null else message | |
| } | |
| this.error = if (validator(this.text.toString())) null else message | |
| } |
This file contains hidden or 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
| --- | |
| Description: AWSAppSync DynamoDB Example | |
| Resources: | |
| GraphQLApi: | |
| Type: "AWS::AppSync::GraphQLApi" | |
| Properties: | |
| Name: AWSAppSync DynamoDB Example | |
| AuthenticationType: AWS_IAM | |
| PostDynamoDBTableDataSource: |
This file contains hidden or 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
| --- | |
| Description: AWS AppSync Notes API | |
| Parameters: | |
| APIName: | |
| Type: String | |
| Description: Name of the API - used to generate unique names for resources | |
| MinLength: 3 | |
| MaxLength: 20 | |
| AllowedPattern: '^[a-zA-Z][a-zA-Z0-9_]*$' |
This file contains hidden or 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
| SNSRole: | |
| Type: AWS::IAM::Role | |
| Description: "An IAM Role to allow Cognito to send SNS messages" | |
| Properties: | |
| RoleName: !Sub ${APIName}-cognito-sns-role | |
| ManagedPolicyArns: | |
| - Ref: CognitoSNSPolicy | |
| AssumeRolePolicyDocument: | |
| Version: 2012-10-17 | |
| Statement: |
This file contains hidden or 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
| UserPool: | |
| Type: "AWS::Cognito::UserPool" | |
| Description: "A Cognito user pool for authenticating users" | |
| Properties: | |
| UserPoolName: !Sub ${APIName}-user-pool | |
| AutoVerifiedAttributes: | |
| - phone_number | |
| MfaConfiguration: "ON" | |
| SmsConfiguration: | |
| ExternalId: !Sub ${APIName}-external |
This file contains hidden or 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
| DynamoDBNotesTable: | |
| Type: "AWS::DynamoDB::Table" | |
| Description: "Data store for AWS AppSync Notes Type" | |
| Properties: | |
| TableName: !Sub ${APIName}-notes-table | |
| AttributeDefinitions: | |
| - AttributeName: "NoteId" | |
| AttributeType: "S" | |
| - AttributeName: "UserId" | |
| AttributeType: "S" |
This file contains hidden or 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
| DynamoDBRole: | |
| Type: AWS::IAM::Role | |
| Properties: | |
| RoleName: !Sub ${APIName}-appsync-dynamodb-role | |
| ManagedPolicyArns: | |
| - Ref: AppSyncDynamoDBPolicy | |
| AssumeRolePolicyDocument: | |
| Version: 2012-10-17 | |
| Statement: | |
| - Effect: Allow |
This file contains hidden or 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
| AppSyncApi: | |
| Type: "AWS::AppSync::GraphQLApi" | |
| Description: "The GraphQL API for the Notes App" | |
| Properties: | |
| AuthenticationType: "AMAZON_COGNITO_USER_POOLS" | |
| Name: !Sub ${APIName} | |
| UserPoolConfig: | |
| UserPoolId: !Ref UserPoolClient | |
| AwsRegion: !Sub ${AWS::Region} | |
| DefaultAction: "ALLOW" |
This file contains hidden or 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
| AppSyncAllNotesQueryResolver: | |
| Type: "AWS::AppSync::Resolver" | |
| DependsOn: AppSyncSchema | |
| Properties: | |
| ApiId: !GetAtt AppSyncApi.ApiId | |
| TypeName: Query | |
| FieldName: allNotes | |
| DataSourceName: !GetAtt AppSyncNotesTableDataSource.Name | |
| RequestMappingTemplate: | | |
| { |