Commit graph

147 commits

Author SHA1 Message Date
Masaaki Goshima
d225e247cc
fix comment map (#635) 2025-02-03 12:54:17 +09:00
Masaaki Goshima
5bac4f35d4
fix comment map (#632) 2025-01-31 09:54:40 +09:00
Masaaki Goshima
e2e4400472
fix sequence value for merge key (#603) 2024-12-22 19:43:53 +09:00
Masaaki Goshima
aeed806d55
Fix cast process for decoding of anchor value (#602)
* add test case

* fix cast process for decoding of anchor value
2024-12-21 21:50:58 +09:00
Masaaki Goshima
54cd51fe01
add nil guard (#600) 2024-12-20 20:10:01 +09:00
Masaaki Goshima
7d56fe29f3
support merge tag (#597) 2024-12-18 10:32:00 +09:00
Oleksandr Redko
342293d734
Replace fmt.Sprint with faster alternatives (#555) 2024-12-13 00:31:35 +09:00
Masaaki Goshima
438f2d0c37
Fix parsing of directive value (#578)
* fix directive

* fix tag value handling

* remove passed test cases

* add comment
2024-12-09 18:45:26 +09:00
Masaaki Goshima
45889c98b0
Fix parser (#557)
* fix document separator with directive

* fix number value with local tag

* fix decoding string for null value

* fix single pair flow mapping

* fix test case

* fix plain lines with tab indent

* fix test case

* fix sequence with null

* fix test case

* fix invalid map-value
2024-11-30 14:47:52 +09:00
Masaaki Goshima
3584ab7d9c
guard stack overflow at decoding (#549) 2024-11-27 17:16:07 +09:00
Masaaki Goshima
23c9234150
add fuzzing test (#548) 2024-11-27 10:48:36 +09:00
Masaaki Goshima
deb129adad
Refactor parser (#545)
* refactor parser
2024-11-26 11:05:45 +09:00
Masaaki Goshima
271213ad23
fix error (#535) 2024-11-14 16:01:08 +09:00
Masaaki Goshima
9c6665c9b4
support to disallow duplicate map key at parsing (#531) 2024-11-13 18:29:20 +09:00
Masaaki Goshima
cb4e1b0610
Support local tag and boolean tag (#527)
* support local tag and boolean tag

* add test case
2024-11-13 00:40:31 +09:00
Shuhei Kitagawa
9ffa1596e7
Fix ordered map comment (#510)
Co-authored-by: Codey Oxley <coxley@users.noreply.github.com>
2024-11-06 18:21:28 +09:00
Masaaki Goshima
e27add428c
fix invalid alias (#497) 2024-11-02 17:40:43 +09:00
Masaaki Goshima
950afad7c7
support recursive anchor (#489) 2024-10-30 19:25:18 +09:00
Masaaki Goshima
548bbc7d4e
Remove xerrors (#483)
* remove xerrors

* move error variable

* update dependencies
2024-10-28 21:24:15 +09:00
alvar
56f8b293f7
Refactor overflowError to be pretty-printable (#470)
When trying to yaml.Unmarshal a negative number into an uint, the
resulting error indicates an overflow with type information, but without
the position. For example:

> cannot unmarshal -23 into Go value of type uint64 ( overflow )

From an end user's perspective reading an error for an invalid YAML,
this is quite unintuitive. Especially compared to the error message when
trying to unmarshal a string into an uint.

> [1:4] cannot unmarshal string into Go struct field Foo.A of type uint64
>     >  1 | a: 'foo'
>               ^

This change has moved overflowError to internal.errors.overflowError,
implementing both the PrettyPrinter and Formatter. Its implementation is
uniform with those of the syntaxError and TypeError.

Thus, the error from above now looks like:

> [1:4] cannot unmarshal -23 into Go value of type uint64 ( overflow )
>     >  1 | a: -23
>               ^
2024-10-28 16:04:03 +09:00
Shuhei Kitagawa
8ad318cffc
Add lint job to CI (#477) 2024-10-28 11:31:15 +09:00
Yonas Habteab
3a90d7186f
Preserve defaults for zero initialised structs as well (#442) 2024-07-30 17:06:24 +09:00
Morris Kelly
b5f63d50d0
Fix decoding of scientific notation (#463)
* Fix scientific notation decoding and add encoding test cases

* Deal with ints and uints

* Add coverage for uint changes
2024-07-16 19:38:06 +09:00
Kirill
7ef5c6272b
support custom unmarshalling for map keys (#453)
Co-authored-by: k.safin@npo-echelon.ru <k.safin@npo-echelon.ru>
2024-06-19 17:51:44 +09:00
Chongyi Zheng
4653a1bb5c
Replace deprecated io/ioutil (#429) 2024-02-26 15:11:21 +09:00
Masaaki Goshima
4052b059bc
Supports dynamically switch encode and decode processing for a given type (#368) 2023-04-02 10:50:03 +09:00
ozraru
8ab464561a
Add support of 32-bit architecture (#350) 2023-03-28 17:49:13 +09:00
Masaaki Goshima
15640065c7
Fix comment option (#349) 2023-03-01 16:59:07 +09:00
Florian Rey
941abdb723 Handle unmarshall unknown aliases 2022-09-16 13:16:00 +02:00
itchyny
f7e91246a5 Introduce MapKeyNode interface to limit node types for map key 2022-08-18 16:16:40 +09:00
Braydon Kains
bf2da56730 internal/errors: moved typeError to errors package
The typeError previously located in decode.go now implements
PrettyPrinter, so it's been moved to internal/errors to be colocated
with the other PrettyPrinter errors.
2022-05-02 18:00:24 +00:00
Braydon Kains
dad2dedc90 yaml: typeError implements PrettyPrinter interface
When unmarshalling YAML and encountering an error in decoded that
results in a `yaml.typeError`, the error can't have the same nice
formatting because it doesn't implement the `errors.PrettyPrinter`
interface. This adds a field to the `yaml.typeError` struct that
specifies a token which is used in the implementation of the
PrettyPrinter interface. The tests were updated to instead match on
expected message substrings instead of full equality.
2022-02-09 23:06:32 +00:00
Masaaki Goshima
ecc53fd595
Merge pull request #260 from Al2Klimov/bugfix/nested-default
Preserve defaults while decoding nested structs
2021-11-18 11:25:45 +09:00
hasheddan
50ca2347b6
Fix minor typo in decodeInit error
Updates error to read 'decodeInit' rather than 'decodInit'.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
2021-11-03 20:37:55 -04:00
Alexander A. Klimov
c6bcb80455 Preserve defaults while decoding nested structs 2021-10-15 15:11:46 +02:00
Masaaki Goshima
b034e1ce7f
Support CommentToMap option 2021-09-07 19:49:15 +09:00
Quentin Smith
f50bfefc06 Wrap conversion errors and add test 2021-08-18 01:13:25 -04:00
Quentin Smith
adc9a196b2 Encode and decode time.Duration fields (#201)
This uses `time.ParseDuration` and `time.Duration.String`, and is
compatible with gopkg.in/yaml's encoding.
2021-08-11 15:07:04 -04:00
Quentin Smith
9340557dea Address review comments 2021-08-11 00:04:14 -04:00
Quentin Smith
24b71a8765 Properly report validation errors from inline fields in strict mode 2021-08-10 03:43:50 -04:00
Quentin Smith
367f635c83 Fix error reporting on inline structs in strict mode (#243) 2021-08-10 00:33:19 -04:00
zoncoen
416f941816
Fix decode nodes included anchors 2021-07-20 02:20:17 +09:00
zoncoen
f6a3c23bf9
Add yaml.NodeToValue(ast.Node, interface{}, ...DecodeOption) error 2021-07-19 21:32:26 +09:00
Nikolai Avteniev
e845c4b76d use yaml structure name in error message 2021-06-29 16:49:57 -04:00
Nikolai Avteniev
de9cea4bd2 Nicely format unexpected node type errors 2021-06-29 16:49:40 -04:00
Nikolai Avteniev
ceb9f9163c Handle missing required field validation 2021-04-24 17:06:35 -04:00
Masaaki Goshima
d1f2ceeb3d Add roundtrip test 2021-03-02 12:24:12 +09:00
Masaaki Goshima
8a0eacffd6 Support to decode ast.Node directly 2021-03-01 13:47:31 +09:00
Masaaki Goshima
d68128d154 Add MarshalWithContext and UnmarshalWithContext 2020-11-11 19:27:58 +09:00
Masaaki Goshima
c395c330c5 Add UseJSONMarshaler option for encoder and UseJSONUnmarshaler option for decoder 2020-10-26 19:00:49 +09:00