cferdinandi / validate

A lightweight form validation script.
MIT License
230 stars 39 forks source link

Restore customError property in the ValidityState() polyfill #46

Open michapietsch opened 6 years ago

michapietsch commented 6 years ago

Hi,

I was missing the customError property when working with setCustomValidity(). I think we can safely assume that a custom error was set when validationMessage contains a message but all the other checks don't qualify.

Regards, Micha

cferdinandi commented 6 years ago

Sorry for being dense, but can you tell me what this PR does? Been a little while since I looked at the code on this. Thanks!

michapietsch commented 6 years ago

Sure, you're welcome! The Constraint API allows to setCustomValidity() to give a custom error message, e.g. "Username already taken" or you can pass an empty string to remove the custom error. This is nice to Integrate additional requirements but still use the Constraint API. The presence of such a custom error is then represented by a property customError: true inside the validityState object. When using the polyfill before this PR, this behavior was overwritten and therefore removed.

michapietsch commented 6 years ago

Sorry, I clicked the wrong button 🙈

cferdinandi commented 6 years ago

Makes sense, thanks! And I do that ALL the time. No worries! I'll get this merged soon.