Skip to content

Commit

Permalink
feat: exclude value > 5 from boolean check
Browse files Browse the repository at this point in the history
  • Loading branch information
caleberi committed Oct 23, 2024
1 parent 3dbe5a8 commit 5ec6800
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/yaml.zig
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,18 @@ pub const Value = union(enum) {
return Value{ .float = float };
}

const lower_raw = try std.ascii.allocLowerString(arena, raw);
for (supportedTruthyBooleanValue) |v| {
if (std.mem.eql(u8, v, lower_raw)) {
return Value{ .boolean = true };
if (raw.len <= 5 and raw.len > 0) {
const lower_raw = try std.ascii.allocLowerString(arena, raw);
for (supportedTruthyBooleanValue) |v| {
if (std.mem.eql(u8, v, lower_raw)) {
return Value{ .boolean = true };
}
}
}

for (supportedFalsyBooleanValue) |v| {
if (std.mem.eql(u8, v, lower_raw)) {
return Value{ .boolean = false };
for (supportedFalsyBooleanValue) |v| {
if (std.mem.eql(u8, v, lower_raw)) {
return Value{ .boolean = false };
}
}
}

Expand Down

0 comments on commit 5ec6800

Please sign in to comment.