json-schema-form / angular-schema-form

Generate forms from a JSON schema, with AngularJS!
https://json-schema-form.github.io/angular-schema-form
MIT License
2.47k stars 653 forks source link

External validator function #929

Open clmntr opened 6 years ago

clmntr commented 6 years ago

Add the possibility to have an external validator function by passing to the validator an expression. Such as : "$validators" : { "equalsEmail" : "mustBeEqual(modelValue, 'email')" }

Description

Add your description here

Fixes Related issues

Checklist

@json-schema-form/angular-schema-form-lead

Anthropic commented 6 years ago

@BulletAnt thanks for this, could you add a quick test case or show me a plunker that shows it working I can make a test case from?

clmntr commented 6 years ago

Sure, will do it when I have some time ;)

clmntr commented 6 years ago

Hi!

I finally took the time to create a plunker that shows the "external" validator.
Here you go: https://plnkr.co/edit/izM9FPnz8O3IewgquxZd

Plus, in my project version (based on the bower version) I also added this to the parsers, and allow the $validators/$parsers/etc... definition directly in the schema. As I use one schema for two forms, it is easier to define those in the schema instead of the form. Let me know if you want me to add this in another PR.

Cheers

clmntr commented 6 years ago

Hi @Anthropic, and Happy New Year !

Do you have any update on this PR ? Should I review some parts ?

Cheers

Anthropic commented 6 years ago

Hi @BulletAnt thanks for the nudge, I missed your Nov update! I'll take a look shortly, Nov-Jan were a write-off unfortunately, way too busy with work and then holidays.