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 support for validation of data type values in runtime #17

Open
2 of 4 tasks
joachimmetz opened this issue Aug 2, 2018 · 5 comments
Open
2 of 4 tasks

Add support for validation of data type values in runtime #17

joachimmetz opened this issue Aug 2, 2018 · 5 comments
Assignees

Comments

@joachimmetz
Copy link
Member

joachimmetz commented Aug 2, 2018

  • signature
  • known values
  • integer bounds
  • expression based such as size == copy_of_size for evt (use validation rules?)
@joachimmetz
Copy link
Member Author

joachimmetz commented Aug 8, 2018

Idea add validation as validation rules:

name: tzif_file_header
type: structure
description: file header.
attributes:
  byte_order: big-endian
validation:
  - tzif_file_header.signature == "TZif"
members:
- name: signature
  type: stream
  element_data_type: byte
  number_of_elements: 4
- name: format_version
  data_type: byte

Pros:

  • supports more complex multi member validation e.g.
(file_header.major_version == 3 and file_header.minor_version == 0) or
(file_header.major_version == 2 and (file_header.minor_version == 0 or file_header.minor_version == 1))

Cons:

  • validation rules are programming language like logic, which makes the format less data driven

@joachimmetz
Copy link
Member Author

Idea add validation in specific "format" types (e.g. signature):

name: tzif_file_header
type: structure
description: file header.
attributes:
  byte_order: big-endian
members:
- name: signature
  type: signature
  element_data_type: byte
  number_of_elements: 4
  expected_value: "TZif"
- name: format_version
  data_type: byte

Pro:

  • expected value part of data type / member definition

Con:

  • less flexible, need (more) specific "format" types
  • unable to support validation of more than 1 member at a time

@joachimmetz
Copy link
Member Author

joachimmetz commented Aug 8, 2018

Idea add validation as parameter of data type definition:

name: tzif_file_header
type: structure
description: file header.
attributes:
  byte_order: big-endian
members:
- name: signature
  type: stream
  element_data_type: byte
  number_of_elements: 4
  value: "TZif"
- name: format_version
  data_type: byte

Pro:

  • expected value part of data type / member definition
  • similar to boolean true_value and false_value

Con:

  • unable to support validation of more than 1 value at a time

Alternative terms:

  • accepted_value
  • expected_value
  • supported_value

@joachimmetz
Copy link
Member Author

joachimmetz commented Aug 8, 2018

Support more than 1 expected value?

- name: format_version
  data_type: byte
  values: [1, 2, 3]

Keep "value: 1" as short hand for "values: [1]" ?

To support minimum and maximum bounds?

- name: format_version
  data_type: byte
  minimum_value: 1
  maximum_value: 3

Alternatives:

  • value_range: min, max
  • value_range: [min, max]
  • value_range: [min, max)
  • value_range: [min, max>

Combine minimum_value and maximum_value into range?

@joachimmetz
Copy link
Member Author

joachimmetz commented Apr 26, 2019

Validation rules:

name: event_record
type: structure
members:
- name: size
...
- name: data_size
- name: data_offset
...
validation_rules:
- event_record.data_size == 0 and event_record.data_offset == 0
- event_record.data_size != 0 and 56 <= event_record.data_offset < event_record.size
  • validation_rules or constraints?
  • Member specific validation rules?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant