New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to use DSL when defining Hash attributes #1172

Merged
merged 1 commit into from Apr 8, 2017

Conversation

Projects
None yet
1 participant
@raphael
Member

raphael commented Apr 8, 2017

No description provided.

@raphael raphael merged commit 5d765a6 into v1 Apr 8, 2017

3 checks passed

continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@raphael raphael deleted the v1.hash_dsl branch Apr 8, 2017

@raphael

This comment has been minimized.

Show comment
Hide comment
@raphael

raphael Apr 16, 2017

Member

Here is an example that takes advantage of the DSLs:

// ValidateKey is a DSL function that defines a pattern based validation.
func ValidateKey() {
	Pattern("^foo")
}

// TypeValue is a DSL function that attaches metadata.
func TypeValue() {
	Metadata("struct:field:type", "json.RawMessage", "encoding/json")
}

// Mappings is a Hash type with validation attached to the keys and metadata attached to the values.
var Mappings = HashOf(String, String, ValidateKey, TypeValue)
Member

raphael commented Apr 16, 2017

Here is an example that takes advantage of the DSLs:

// ValidateKey is a DSL function that defines a pattern based validation.
func ValidateKey() {
	Pattern("^foo")
}

// TypeValue is a DSL function that attaches metadata.
func TypeValue() {
	Metadata("struct:field:type", "json.RawMessage", "encoding/json")
}

// Mappings is a Hash type with validation attached to the keys and metadata attached to the values.
var Mappings = HashOf(String, String, ValidateKey, TypeValue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment