1

I have a form with an input that is "required". This is perfect when your value is just a text.

I also have a directive that outputs a json string. I want also to validate this json before submitting the form.

I can't create an input with this ng-model because inside that input says [Object]. Is it a good practice to stringify this json and create a custom validator that validates the json?

1
  • I'd recommend having an ng-change, validating JSON in there and setting validity using <inputName>.$setValidity Commented May 15, 2017 at 8:46

1 Answer 1

1

No it's not a good practice, you should not do that instead u make different inputs for different properties of JSON because stringify can't validate your JSON. Json should be either dynamically created for when the form has been submitted after validation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.