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 constraints to #Lineage.name #66

Open
sdboyer opened this issue Aug 19, 2022 · 2 comments
Open

Add constraints to #Lineage.name #66

sdboyer opened this issue Aug 19, 2022 · 2 comments
Assignees
Labels
invariants Involves the definition or enforcement of a key system invariant

Comments

@sdboyer
Copy link
Contributor

sdboyer commented Aug 19, 2022

At minimum, we want:

  • strings.MinRunes(1)
  • ~=[z-aA-Z0-9_]

Probably the ideal target is the set of valid characters for an unquoted CUE label. That covers another known, future use case by disallowing slashes - important to be able to introduce e.g. an optional #Lineage.uri property later, and enforce that its trailing element is == #Lineage.name and be able to know a priori that there is only one trailing element.

Again, we can open this up more later. Opting for restrictiveness initially gives us more options later.

@verdverm
Copy link

I've been thinking about restricting some names in hof in a way that matches k8s & DNS Label Names. Should be something like:

name: =~ "^([[:alpha:]][[:alnum:]-]{0,61}[[:alnum:]]|[[:alpha:]])$"

https://cuelang.org/play/?id=kuNNBpN464J#cue@export@cue

https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names

One thing to consider is that if you are mapping these names to filenames or paths, Mac does not distinguish between upper & lower case.

@sdboyer
Copy link
Contributor Author

sdboyer commented Aug 23, 2022

Oooh, that's helpful.

i was already thinking i'm gonna end up having to allow -. That one actually works less well than underscores for generated symbol names, where most languages disallow it - but for a name, i think that's probably less important. (It also screwed up the logic in Thema for internally generating a def of each schema in the lineage, for closed validation purposes.)

That doing dashes but not underscores aligns with dns naming and k8s makes the path here seem pretty clear.

also

[:alpha:]][[:alnum:]

Mmm, for a schema that's likely to be frequently read by human eyes, i definitely do like using the named ASCII character classes more than writing them out raw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invariants Involves the definition or enforcement of a key system invariant
Projects
None yet
Development

No branches or pull requests

2 participants