Commit graph

160 commits

Author SHA1 Message Date
Shuhei Kitagawa
6a6c998c2f
Prevent panic when decoding string named types (#743) 2025-05-26 09:14:35 +09:00
Shuhei Kitagawa
04f9bb53f7
feat: Dont make copies of structs for validation (#737)
* feat: Dont make copies of structs for validation

* Remove the unnecessary if statement and its corresponding unit tests

---------

Co-authored-by: Pavel Pletenev <cpp.create@gmail.com>
2025-05-23 11:02:23 +09:00
Masaaki Goshima
e61dcd0829
set null value for empty document (#725) 2025-05-08 00:40:41 +09:00
Shuhei Kitagawa
427b18e1b7
Avoid returning an error for null document (#721) 2025-05-07 21:29:47 +09:00
Masaaki Goshima
9d0a7f2b35
fix validation error position for container type (#716) 2025-05-06 00:47:34 +09:00
Shuhei Kitagawa
82ba1baaaf
Update golangci-lint to v2.1.2 (#701) 2025-05-05 23:32:21 +09:00
Masaaki Goshima
98988fe899
fix comment map with no body (#682) 2025-03-31 17:03:05 +09:00
Denys Sedchenko
53701ccf36
feat: support receiving ast.Node in custom unmarshalers (#642)
* chore: ignore GoLand files

* feat: add NodeUnmarshaler and NodeUnmarshalerContext support
2025-03-16 19:31:01 +09:00
Masaaki Goshima
b46780d4c8
Keep reference of anchor's value (#660)
* keep reference of anchor's value

* add test case
2025-02-16 16:44:00 +09:00
Masaaki Goshima
48e793c9e0
fix unmarshal text (#649) 2025-02-11 22:48:22 +09:00
Masaaki Goshima
8f17441eeb
Fix format with alias (#648)
* fix format with alias
2025-02-11 22:02:56 +09:00
Masaaki Goshima
c331468e5b
support entry token for flow style. (#646)
- add sequence entry node for flow sequence.
- add collect entry token field to mapping value node for flow mapping.
2025-02-11 12:15:41 +09:00
Masaaki Goshima
0653c80843
add node formatter (#644) 2025-02-09 14:42:50 +09:00
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