question: support for validating property as string or string[]
See original GitHub issueHi, how could I validate a string or array of strings?
I have in my class:
@IsString()
public parameter: string | string[];
Is there a way to tell to class-validator that the parameter could be string or array?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to Validate String Properties in Business Objects
There are two more tricks that we wish to demonstrate about string validation. First one deals with putting a lower limit on string...
Read more >Want to validate a string using property in C# [closed]
When validating within set accessor you should chech value , not backing field categoryName which should have already been valid:
Read more >Custom Edit Validate | Support Center
Creating Edit validate rule and comparing 2 dates using java code. The 2 dates are properties in application.
Read more >How To Use Schema Validation in MongoDB - DigitalOcean
Step 2 — Validating String Fields. In MongoDB, schema validation ... The next property in the validation document is the required field.
Read more >Frequently Asked Questions - python-jsonschema
The JSON Schema specification does not deal with how to apply the patternProperties keyword to non-string properties. The behavior of this library is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
No Answer for a whole year…
Proper fix
The proper way would be to change
interface ValidationOptions
, replacingeach?: boolean;
byeach?: boolean | "optional";
then add some changes incustomValidations
and change in ‘ValidationExecutor’ and update the error message generation logic.Please let me know if you think I should try a PR.
Quick fix
For now, the easiest way is to write your validator:
File:
IsStringOrStrings.ts
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.