-
Notifications
You must be signed in to change notification settings - Fork 171
Semver as a basic type like number or string #407
Comments
I don't think this should be a bulitin. It'd be better to have a generic method of creating user-defined types with these semantics. Like maybe define the comparison operator on lists be a lexicographic ordering. |
Another similar problem is expressing date and time ranges, which I don't think is currently possible in cue (unless you just using unix epoch seconds or something). |
I think you are right, so I'll update this to be semver as a built in package in Cue. See the 'pkg/**' packages available. There are things for dates, ips, and more. Semver comparison can likely fit here via functions. I'm not sure there is a path for user defined types which can be used in builin operations like < and other Boolean ops. @mpvl ? |
The simplicity of not allowing re-definition of Instead, this situation (and many others) sound like a use case for the previously proposed |
@rvadhavk: time.Time enforces a proper string type and you can just use string comparison for ordering. There is no need to redefine Semver can easily be expressed as a fairly simple regexp. The only thing I can imagine that would be useful is numeric sorting (e.g. using x/text/collate). Again, this can be solved with a more generic package. I don't think it warrants a builtin package. It can easily be provided as a native CUE package externally. I don't think semver is at the same level of standardization as ip or dates. |
This issue has been migrated to cue-lang/cue#407. For more details about CUE's migration to a new home, please see cue-lang/cue#1078. |
Configuration is often dealing with versions and there is not an easy way to compare version identifiers during validation and evaluation.
Having a
semver
basic type (not sure the right term here) likenumber
andstring
.This seems like a good library to use: https://pkg.go.dev/golang.org/x/[email protected]/semver
The text was updated successfully, but these errors were encountered: