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 a field-based constraint for timestamps #46

Open
popematt opened this issue Jul 13, 2021 · 0 comments
Open

Add a field-based constraint for timestamps #46

popematt opened this issue Jul 13, 2021 · 0 comments
Labels
enhancement New feature or enhancement for the Ion Schema _specification_ requires new version Something that should be considered for next version of the Ion Schema Specification

Comments

@popematt
Copy link
Contributor

Currently, you can create a constraint on the n lowest precision fields by restricting a timestamp with a range (ie. using valid_values), and you can restrict the n highest precision fields to be 0 by placing a restriction on the timestamp precision. However, you cannot constrain an arbitrary field within a timestamp without placing a constraint on any of it's "neighboring" fields (eg. you can't constrain days without also constraining either months or hours) nor can you constrain a high-precision field to be something other than 0. It would be useful to be able to define constraints on specific fields within a timestamp.

Example use cases:

  1. All timestamps in your data model must have seconds precision (by chosen convention, or perhaps because of some framework in use), but you want to restrict a certain value to have minutes and seconds of zero.
type::{
  name: my_app_timestamp,
  timestamp_precision: seconds,
}

type::{
  name: start_of_hour_timestamp,
  type: my_app_timestamp,
  timestamp_fields: {
    minute: 0,
    seconds: 0
  }
}
  1. Timestamps represent buckets that have a specific granularity
type::{
  name: five_minute_bucket,
  timestamp_fields: {
    minute: [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],
    second: 0,
  }
}
@popematt popematt added enhancement New feature or enhancement for the Ion Schema _specification_ requires new version Something that should be considered for next version of the Ion Schema Specification labels Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement for the Ion Schema _specification_ requires new version Something that should be considered for next version of the Ion Schema Specification
Projects
None yet
Development

No branches or pull requests

1 participant