Compare commits

...

2 Commits

Author SHA1 Message Date
f220cb62bc
validator: fix empty check 2025-04-12 12:31:05 -07:00
f090fd7d68
validator: fix duplicate checks 2025-04-12 12:29:17 -07:00

@ -220,7 +220,7 @@ impl std::fmt::Display for StringEmpty{
}
}
fn check_empty(value:&str)->Result<&str,StringEmpty>{
value.is_empty().then_some(value).ok_or(StringEmpty)
(!value.is_empty()).then_some(value).ok_or(StringEmpty)
}
// check for duplicate objects
@ -394,7 +394,7 @@ impl<'a> ModelInfo<'a>{
.check(&self.counts.mode_start_counts);
// There must be exactly one start zone for every mode in the map.
let mode_start_counts=DuplicateCheckContext(self.counts.mode_start_counts).check(|c|c.len()<=1);
let mode_start_counts=DuplicateCheckContext(self.counts.mode_start_counts).check(|c|1<c.len());
// Check that there are no Teleports without a corresponding Spawn.
// Spawns are allowed to have 0 Teleports.
@ -402,7 +402,7 @@ impl<'a> ModelInfo<'a>{
.check(&self.counts.spawn_counts);
// There must be exactly one of any perticular spawn id in the map.
let spawn_counts=DuplicateCheckContext(self.counts.spawn_counts).check(|&c|c<=1);
let spawn_counts=DuplicateCheckContext(self.counts.spawn_counts).check(|&c|1<c);
// Check that at least one WormholeIn exists for each WormholeOut.
// This also checks that there are no WormholeIn without a corresponding WormholeOut.
@ -410,7 +410,7 @@ impl<'a> ModelInfo<'a>{
.check(&self.counts.wormhole_out_counts);
// There must be exactly one of any perticular wormhole out id in the map.
let wormhole_out_counts=DuplicateCheckContext(self.counts.wormhole_out_counts).check(|&c|c<=1);
let wormhole_out_counts=DuplicateCheckContext(self.counts.wormhole_out_counts).check(|&c|1<c);
MapCheck{
model_class,