Open jayceekay opened 11 years ago
Yeah, sorry I missed this. There should be, I'll keep this open just to make sure I document it... I've been working on finishing up some things here and getting a release out.
+1 for baked in unique validation
@tgriesser I understand that this might be considered outside of the scope of checkit. If so, do you have any recommendations for unique constraints and error/message handling outside of checkit? Or, is this just something you haven't gotten around to yet?
@jpdesigndev @activestylus @jayceekay, could you please elaborate on each of your exact use cases for a unique constraint?
Do you mean a unique value in the object passed to the validator? (i.e. that value only exists once in all the properties on the object)
Or perhaps you mean something different?
In my own code I've been able to do custom messaging with a custom validation function by returning Promise.reject(new CustomError('My custom thing is invalid'))
when there is an issue. Would something like this suit your needs?
that was 2.5 years ago and not relevant to me anymore. also cannot remember my use case. :)
Maybe this is a silly question since it requires performing a query to validate it, but is there any way of implementing a unique validator? Or perhaps some standard workaround that I'm not aware of?
I'm also having a problem finding out where I could catch whatever error the mysql driver is returning when the insert fails the db level enforced unique constraint.
This is what I'm seeing when I attempt to insert something that fails the db level unique validator (username in this case; I reformatted the JSON for readability):