You might also get a question like this for Vermont beckoned validation message to front and far from
it.
And actually, this is a real example because sometimes we're getting beckoned validation messages,
not in the format.
How would a suitable for us in the frontend for our JavaScript farms?
This is way here where I get to know about errors in such format.
We have here an object whiskey's and every single key is a property from the backend.
So our field that we are validating, for example, email and here we have field errors.
And this is what is interesting for us.
Errors is in the array of objects and inside every single object.
We have message property with some message.
For example, here we have password with two errors.
This is why here is an array with two objects.
Here is a message must contain symbols in different keys and must be at least eight symbols lens.
So what we want to do in this exercise, we want to convert it to our front and format.
And this is just a plain array with strings, and every single string is our key.
So our field like email and now we have all our concatenated mistakes like, for example, can be blank.
And if we have two of them, then we simply concatenate them with common.
So actually, you can solve it in different ways, but I highly recommend to use object energies here.
We can simpler right here objects and trees and provide inside our back and errors.
And as you can see, we're getting such a nice format like array of rays, and every single array here
is first to follow a key and the value is what we had here.
So we have a value with errors and inside we have our errors.
And this is really comfortable format to work for us because we come through a local map in JavaScript
on the object.
This is why what we want to do here, we want, first of all, to create some normal property, maybe
a human readable, beckoned errors and no one to call here object entries.
And we want to provide inside our back and errors.
So actually, now we have array of race and we can map here every single value.
And you already saw what we are getting here.
We get an array with email as a key and some value.
And actually, here I want to use directly this structuring to get, first of all, our key and second
look, we're getting our value.
This is the easiest way how you can use a map on the object.
And here we get it.
First of all, our field and secondly, value with the errors.
This is why we must prepare our errors.
In this case, let's name them, for example, field messages, and we must concatenate them so we can
write here value dot errors.
So we're getting our array of errors.
And now here we need to map every single error.
So here were Colin Map without error and we want to return error dot message.
And as you can see here, this is true.
We have here array with objects and every single object contain our message.
So here we're just mapping this message.
And after this one to concatenate them.
So here I will put join comma and space because we want to have a nice, readable string.
And after this, we simply need to return our string because we're inside the map here.
So I want to use here ActionScript 16 and inside.
I want to provide our key.
But here the problem is you can see it is always capitalized.
So first of all, we must capitalize it, and we already did it in previous videos.
This is where here we can name it, capitalize field.
And actually, I think feel this better name, Celestron name our key to field.
And now here we must call on field first default character at zero in this case, where taking our first
element and we want to concatenate it with field dot slides and here where Putin wants a work cut and
one symbol in this case, it is our capitalized name of the field.
Now here we must provide this capitalized field.
And here is important.
In other case, we can think that this is a function and after this was simply put, column space.
And here are our field messages.
So what we are doing here, where may have been through our object entries, were getting directly our
field and value.
First of all, we are changing our field messages.
And secondly, there could be delays in our field and no return is true for every single error.
Let's check the sour time to load in our page, and let's check what we have inside human readable errors.
And as you can see, this is a nice array in the correct four month.
So we have history for every single field and we capitalized the name of every field.
And here we joined our errors, which means we're successful to solve this problem and transferring
data in the correct format.