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

Version 2 #186

Open
4 of 9 tasks
tlsa opened this issue May 15, 2022 · 13 comments
Open
4 of 9 tasks

Version 2 #186

tlsa opened this issue May 15, 2022 · 13 comments
Milestone

Comments

@tlsa
Copy link
Owner

tlsa commented May 15, 2022

  • Add union support
  • Replace LibYAML
  • Add CYAML_CUSTOM type
  • Support C99 flexible array members
  • Deep clone
  • Default values
  • Min/max values for integer fields
  • General client value validation callback
  • Binary type
@ccoustet
Copy link

Hi Michael. All these features sound great! I'm currently interested in unions and validation callbacks, but others could be interesting in other projects. Is there already a release timeframe for V2?

@ccoustet
Copy link

I don't know if you are interested in suggestions (that is additional work), but I would found very useful to have custom log messages (through callbacks?), including verbose success reporting. And a boolean set/unset for optional fields could be a good feature too.

@ccoustet
Copy link

Another feature I would like is to be able to (optionally) store the parsing context of a value. Could be limited to line+column and a pointer to the parent item, all the way up to the top-level item.

@MasterMind2k
Copy link

@tlsa, do you have any spec/plan how you intend to implement default values and validation? On project I am working on I've created a small layer to get this in (and is very cumbersome) and I'm interested to help out on this two areas.

@ccoustet
Copy link

ccoustet commented Apr 6, 2023

Hi!
As I see that these topics are discussed, I give my feelings again.
Default values could be solved easily if a set/unset information is added: if the field hasn't been set I can set it with a default value, possibly depending on some read values.
The topic of validation is far more complex. For context-free validation, a simple optional user callback could do the job. The problem is that some constraint can only be checked across a set of fields (if x is true y must be positive). In this case the validation process could only occur post parsing. The lib can help this however by optionally recording some context information that could be used to inform warnings/error messages.

@MasterMind2k
Copy link

MasterMind2k commented Apr 6, 2023 via email

@ccoustet
Copy link

ccoustet commented Apr 7, 2023

I agree. Complex validation can only be user ad-hoc code.
What I was trying to advocate is that some information is needed to output meaningful messages, like parsing context (e.g. line and column begin end for the field, parent field, ...).

@tlsa
Copy link
Owner Author

tlsa commented Apr 11, 2023

My current thinking is that I'll add min/max values for validating numerical values.

For mappings I'll add a validation callback option, which will be called on the mapping end event.

What I was trying to advocate is that some information is needed to output meaningful messages, like parsing context (e.g. line and column begin end for the field, parent field, ...).

I don't think that will be necessary. If the client validation callback fails, libcyaml will return a new error code indicating client validation failed, and that will cause the load to abort, and the existing backtrace logging will be used which will contain the position of the mapping that failed to validate. The client itself will have to log what it didn't like about the mapping.

@ccoustet
Copy link

ccoustet commented Apr 12, 2023 via email

@tlsa tlsa added this to the Version 2 milestone May 28, 2023
@tlsa
Copy link
Owner Author

tlsa commented May 29, 2023

Default values are now implemented on main.

To use them you need to use the new-style schema building macros.

The old style ones continue to work, they are implemented as wrappers for the new style macros.

It is possible to use the new style macros only for fields that require the new features, for example, the schema in test_load_mapping_field_default_u8.

@tlsa
Copy link
Owner Author

tlsa commented May 29, 2023

Min/max values for integer values is now implemented on main.

@tlsa
Copy link
Owner Author

tlsa commented May 30, 2023

Client value validation callbacks added in this PR: #217. I still need to add tests.

@tlsa
Copy link
Owner Author

tlsa commented Jun 1, 2023

Validation callbacks are now merged.

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

No branches or pull requests

3 participants