Strapi
Published in

Strapi

Personal Pull Request Logs — Strapi beta.20

Strapi beta.20 is out, unleashing content with a brand new Media Library, a guide on deploying to the Google App Engine, and more!

Similar to what we did for Strapi beta.19.4, we want to focus on a couple contributions, highlighting the contributors behind the development.

We’re looking at Yassir Barchi and Vasyl Rashko for today’s post, diving into how they contributed to the Strapi repo by adding RegExp as a text type attribute and fixing default values on create entities.

Before jumping into the Personal Pull Request Logs, take a quick look at the full list of bug fixes and features over on Github for a recap of what’s new in Strapi beta.20.

Yassir Barchi — RegExp as Validation Option

[core:framework] Add RegExp as text type attribute validation option (#5648) @yacir

Yassir Barchi was building an internal tool at this company, an implementation of Strapi to help project managers and marketing teams, when he ran into an issue that he had to solve before continuing his work.

In order to ensure the content generated by the admin panel wasn’t broken, he needed to ensure specific validation layers. One of the simpler examples was finding a way to ensure URL fields are always in HTTPS.

While looking through the Strapi roadmap, Yassir noticed that a “validations” feature was planned, but it didn’t look like progress was likely within the year. With plans for 2020 already mapped out and defined, the long wait was understandable. Especially considering Strapi’s limited manpower.

Seeing that he needed to implement a solution for his own needs and that it was already a trending feature under consideration, he decided to officially implement the feature to help the community. For Yassir, it’s a way to say “thank you” to the core team for all the work they do to make Strapi stand out.

So he went about seeing how best to add his code to the repo by first finding the previous pull request he needed to fix:

After finding the initial issue and discussing how best to implement it with core members of the Strapi team, Yassir’s contribution was added to Strapi!

Whenever Yassir comes across an issue while working with open source he tries to go the extra mile. Rather than just being a passive user, he sees it as important to help the community when it’s possible. In the end, it’s that effort to add to a project’s collective knowledge that gives open source so much power.

Vasyl Rishko — Default Values on Create Entity

[core:framework] Fix default values on create entity. (#5675) @VasylRishko

Vasyl’s story of contributing to Strapi, similar to many others, starts with a professional project. He was working on a RESTful API for a mobile app when an error message came up. Rather than giving up or finding a solution that only worked for his use case, he decided to contribute to the repo and made a pull request.

The details came into focus when Vasyl noticed a bug with validations with Strapi. Specifically, validations when creating a record using the default and required attributes. In his case, it was a pesky problem with a recurring error message.

Everything here should normally be taken care of with an automatically assigned default value. Since that wasn’t happening, Vasyl dived into the code and looked into why that wasn’t the case. After all, solving the problem for himself could help any future devs dealing with these validation bugs as well.

Wanting to squash the bug and avoid problems with reproducing an obscure error or illogical issue, Vasyl also provided a nice example of exactly what was happening and how it differed from the expected results:

Model settings example:

{
"kind": "collectionType",
"attributes": {
"someAttr": {
"type": "string"
},
"testAttr": {
"type": "boolean",
"default": true,
"required": true
}
}
}

Request:

POST /entity HTTP/1.1  
Content-Type: application/json
{
"someAttr": "test"
}

Response:

{
"statusCode": 400,
"error": "Bad Request",
"message": "ValidationError",
"data": {
"testAttr": [
"testAttr must be defined."
]
}
}
}

After making the initial pull request, Vasyl then discussed the details of it with Alexandre Bodin, finding the best approach to implement the solution on as wide a scale as possible — and without breaking anything else!

The two devs narrowed the errors down to a few specific details, ending up with an important contribution to Strapi beta.20 that will help countless others avoid headaches and code-aches in the future.

While fixing the validation bug he also ran into another issue: validation for unique records returns 500 instead of 422 with an error message. He hasn’t jumped on fixing that bug quite yet, but he’s already feeling motivated to tackle it soon, doing what he can to make sure everyone has a smoother Strapi experience.

Strapping in for the Next Strapi Release!

The community of people behind Strapi who supports the open-source project are the heroes of every release, every update, and every feature. The patch notes and changelogs make the end results more pragmatic and easier to digest, but it’s always nice to take a look at the person behind the pull request.

These Personal Pull Request Logs and the stories of how devs decide to contribute to Strapi help us shine a light on that passion, sharing more from the community and going beyond what’s on GitHub.

Keep your eyes out for another Personal Pull Request Logs with the next Strapi release!

As always, check out the full changelog on GitHub for all the details of what’s new in Strapi beta.20.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store