How to write and use templates with package #1028
-
Hello, I am brand new to cue. I'd like to use it to define a template and a set of constraints for data schema. Here is a quick summary of what I am trying to achieve: My tests package event
// Definition of the envelop
#Envelop: {
subject: =~"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" // a uuid
source: =~"^net.mycompany.+"
type: =~"^net.mycompany.+:[cud]" // c : create u : update d : delete
dataContentType: string
}
#Data: {}
#Event: {
envelop: #Envelop
data: #Data
} I made a sample data producer and the directory tree looks like this:
And the
Now to the questions:
(it works if I replace the
I guess that I may have misunderstood an underlying concept of the language. Thank you for your help. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Don't you need to prefix the call to #event with the event namespace (last segment of the import string) ? |
Beta Was this translation helpful? Give feedback.
-
First self-answer, the
|
Beta Was this translation helpful? Give feedback.
-
Here is a working example:
and the schema for the producer:
And a sample data:
|
Beta Was this translation helpful? Give feedback.
-
This discussion has been migrated to cue-lang/cue#1028. For more details about CUE's migration to a new home, please see cue-lang/cue#1078. |
Beta Was this translation helpful? Give feedback.
Here is a working example:
and the schema for the producer:
And a sample data: