Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array of strings? #94

Open
jdbool opened this issue Mar 30, 2019 · 2 comments
Open

Array of strings? #94

jdbool opened this issue Mar 30, 2019 · 2 comments

Comments

@jdbool
Copy link

jdbool commented Mar 30, 2019

Looks like this is the only way, which is really messy.

.array('strings', {
	type: new Parser()
		.string('text', {
			length: 64,
			stripNull: true
		}),
	length: 'stringCount'
})

That would result in something like this:

"strings": [
	{ "text": "hello" },
	...
]

Something more ideal would just be an actual array of strings:

"strings": [ "Hello", ... ]
@p0358
Copy link

p0358 commented Dec 12, 2019

.array('strings', {
	type: new Parser()
		.string('text', {
			length: 64,
			stripNull: true
		}),
	length: 'stringCount',
	formatter: arr => arr.map(item => item.text)
})

The only way I see tbh (but it works!)

@Rechdan
Copy link
Contributor

Rechdan commented Oct 18, 2020

Just made this "workaround" for the array of strings, but an options to actually make a proper array of strings would be very welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants