Skip to content
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
Merged

Conversation

raphael
Copy link
Member

@raphael raphael commented Apr 8, 2017

No description provided.

@raphael raphael merged commit 5d765a6 into v1 Apr 8, 2017
@raphael raphael deleted the v1.hash_dsl branch April 8, 2017 23:55
@raphael
Copy link
Member Author

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant