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

Feat/payload validation #137

Closed
wants to merge 2 commits into from
Closed

Conversation

Khaledgarbaya
Copy link
Contributor

This PR adds payload validation for the entities to be imported based on a JSON schema.
If the one of the entity's payload is invalid it will be removed from the array and it a nice warning will be logged telling the user which field is missing and the entity id if possible.

Why?

  • centralize all checks in one pass.

This is still a WIP PR I would like to get your inputs on it and how strict should we go in the schema validation.

@zcei
Copy link
Contributor

zcei commented Dec 15, 2017

telling the user which field is missing

This would involve a lot of dynamic schema building, as you need to compile a new JSON schema per Content Type to check an Entry against it.

I would probably only check for keys that are required to pass our Management API, e.g. a field in a ContentType needs the type property.

While building the migration tooling we used joi and even there hit some limitations, so only JSON Schema would be very ambitious if you plan to validate Entries.

I recently found superstruct, haven't used it yet, but might a good fit.

@Khaledgarbaya
Copy link
Contributor Author

@zcei I don't want to go crazy with the validation, I will just make sure the keys expected by the transformation pass and by the management api.
stuff like assets without file field etc

@axe312ger
Copy link
Contributor

I like this idea a lot :)

Superstruct looks pretty nice, also :)

Lets discuss monday :)

@axe312ger
Copy link
Contributor

@Khaledgarbaya I guess we can close this in favour of contentful/contentful-import#81?

@Khaledgarbaya Khaledgarbaya deleted the feat/payload-validation branch February 7, 2018 15:17
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

Successfully merging this pull request may close these issues.

None yet

3 participants