3 ms·
I just compiled the code provided in the article and the compiled WASM module is 22kb. Not saying that it makes it the right solution, but a 45× difference is n
by milliams 1y ago
I just compiled the code provided in the article and the compiled WASM module is 22kb. Not saying that it makes it the right solution, but a 45× difference is not insignificant.
- remram 1y agoBut the example code doesn't do much validation. If you did want to use a regex, you would have to compile and bundle the regex crate...
- littlestymaar 1y agoAnd what kind of form validation are you going to do with a regular expression? E-mail addresses like every other fool? (This is a the best to reject perfectly valid addresses because you baked unjustified assumptions in you regex)
- porridgeraisin 1y agoFor what it's worth, the inbuilt HTML5 validation that implementw input type=email does have a regex in the spec. https://html.spec.whatwg.org/#email-state-(type=email) https://html.spec.whatwg.org/#email-state-(type=email) /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/ But it is true that you can implement it with a FSM(which is what firefox does). Webkit uses a regex as well I think.
- drowsspa 1y agoYeah, for all intents and purposes that's the spec for emails now
- littlestymaar 1y agoTIL thanks.
- zoechi 1y agoThe bigger and more complex the application, the less is the effect of this.
- remram 1y agoMe? None. I'm not the one proposing the use of Rust and WASM for form validation. What kind of validation are you going to do without a regular expression?
- littlestymaar 1y ago> What kind of validation are you going to do without a regular expression? Actual form validation… I can't even think of a single kind of form validation where a regex would help…
- 01HNNWZ0MV43FF 1y agoWith `regex-lite` I got under 100,000 bytes on the email regex in the sibling comment. Not great, not terrible.