Closed sldhana-zz closed 7 years ago
Hmm, if pattern is present it is validated... I see the case for making blank override this but I'm not sure if that'd break compatibility w/ JSON schema. Is it an option to make your secondary regex accept blank strings as well?
@jamesturk - seems like then I have to specify the regex differently for each optional field. I am trying to do this with dynamic form generation. Could you explain the compatibility with JSON schema? Is it because each key should be independent and not rely on each other?
That's fair. I'll try and figure out which is expected behavior from JSON schema's point of view (it's basically a question of precedence, IIRC this might be vague in the draft spec)
On Tue, Sep 6, 2016 at 8:02 PM, sldhana notifications@github.com wrote:
@jamesturk https://github.com/jamesturk - seems like then I have to specify the regex differently for each optional field. I am trying to do this with dynamic form generation. Could you explain the compatibility with JSON schema? Is it because each key should be independent and not rely on each other?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jamesturk/validictory/issues/105#issuecomment-245133700, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAfYiXBnT8kavRY80yXSw7oCr4gfQf1ks5qnf79gaJpZM4J0qmW .
closed in light of #114
I have a schema like this. The
secondary_email
should only be validated if it contains anything other than an blank value. But with this schema, the pattern is always being used to validate a blank value and it fails validation.Next approach was to do this:
I then have a custom email function that checks the
format_option
and determine whether it contains the wordoptional
or not. If optional, I then only validate ifvalue
is not empty. Although this works, this solution doesn't seem very elegant. Am I missing something that I could do much simpler?