validator icon indicating copy to clipboard operation
validator copied to clipboard

Return error code for API application

Open ghost opened this issue 1 year ago • 6 comments

Return error code for property validate rules on API application.

ghost avatar Jan 29 '24 10:01 ghost

Would you please elaborate with some example? It's not clear now.

samdark avatar Jan 29 '24 10:01 samdark

As in symfony: https://github.com/symfony/validator/blob/bf0e20ac57f038ef6ea52f83aa474b5f567ff9a1/Constraints/Email.php#L29

Every error has individual code.

vjik avatar Jan 29 '24 11:01 vjik

Would you please elaborate with some example? It's not clear now.

Example

errors: [
{
      "propertyPath": "email",
      "message": "Test message",
      "code": "inavalid_email"
    }
]

ghost avatar Jan 29 '24 11:01 ghost

I see. That makes sense if client needs to handle errors of a kind in a special way.

samdark avatar Jan 29 '24 18:01 samdark

Need to decide where exactly the code will be attached to. Will it be a rule / individual error / similar errors (incorrect input, etc.)?

arogachev avatar Apr 12 '24 08:04 arogachev

Need to decide where exactly the code will be attached to. Will it be a rule / individual error / similar errors (incorrect input, etc.)?

I think need add individual codes to individual errors. Also need ability change code as in concrete rule as in globally.

vjik avatar Apr 12 '24 11:04 vjik