Closed kakasoo closed 1 year ago
Not possible because JS does not support the decimal type.
Instead, I will consider custom random generator which can get special custom comment tags.
I think I have a misunderstanding about this library. Is the validation logic of this library purely JS spec? Including typia.random method?
OK, Thanks for answering. 😅
Adding decimal validation is not possible, but random() would be customizable.
I will provide comment tags info into the IRandomGenerator
, then you can customize it.
As you said, writing test codes will be very, very easy. That's the feature I wanted! Today I learned more deeply how to use typia.
Also about the validation, no way to check the decimal number exactly in the floating number system.
If you want to specify number range to be randomly created, utilize those tags:
Wait, wait, wait. What if you use your @pattern to verify the number string? Even if it's not a number, is this possible?
Yes, possible only when string
Then I will change the type to number string and then use the method of verifying with pattern. It is unfortunate that decimal verification is not possible, but using patterns seems like a good idea. It's a separate question, is the @pattern impossible for the string literal type?
Use such tags, then everything would be fine
You are a genius!
My image type has decimal values called "position" as follows. When I created a fake image using "typia.Random()", postgres kept spitting "numeric field overflow" errors. I now know the reason for this error. "Typia.Random()" generates random values using type and comment tags, and the problem is the decimal point. Endless decimal places ignore DB constraints. "Typia.Random()" produced a number below a decimal point that was too long. This was a value that ignored precision 6 and scale 5 of the DB column. Come to think of it, it's natural, but we need a way to stop this.
So I would like to suggest the following. ( I looked up the issue of this project, but I don't think a similar feature has been proposed yet. ) . .
This is a suggestion, and even if it is not this way, I would welcome any way to limit the numbers below the decimal point.