mdedetrich / scalajson

ScalaJSON - JSON for Scala, currently contains minimal AST
BSD 3-Clause "New" or "Revised" License
55 stars 10 forks source link

Override .copy in JNumber to use regex #33

Closed mdedetrich closed 7 years ago

mdedetrich commented 7 years ago

@sirthias @Ichoran @ktoso

The idea is to override the copy method (both in the case class and class variants) so that it checks the String that you are copying is valid. Since the types have to line up we would have to throw an exception.

If this isn't done, its possible to to have an instance of JNumber with an invalid number inside.

Ichoran commented 7 years ago

Agreed. This is necessary if JNumber is going to be a case class. It is a shame, though, because copy isn't the feature of case classes that we want to preserve here.