Should Parser Validate the Entire TOML File Before Returning the Found Queried Value? #1035
-
Hi, say the parser already found a queried value by a given key half-way parsing the TOML file, should the parser continues to validate the entire toml file's validity or can it return early? Please consider both small and very large file (e.g. TB sized). Let's assume somewhere is the last quarter of the TOML file is both valid and invalid. CONTEXT: I'm asking to for comparing with other data types like JSON where the full file validation is strictly required. Hence, JSON is not a suitable data spec for large file. TOML specification did not specify this requirement (https://toml.io/en/v1.0.0#objectives). Currently writing a parser library for POSIX compliant shell script using 1.0.0 spec. The reason I'm asking for both small and very large file is mainly to develop an adaptable and scalable algorithm. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I'd say for that specific use case there's no reason for the parser to read and validate the rest of the file. At least I don't think there's anything in the spec that says so. |
Beta Was this translation helpful? Give feedback.
We never took text streams into account when defining the standard, which wasn't intended to be a data serialization format. That would be nice, but we never considered it. It's not a common configuration use case.
There's a remote possibility that a table or key will be defined more than once on a stream, which would invalidate the complete TOML text. Like so:
Or like so:
Since the stream parser co…