adonisjs / validator

Schema based validator for AdonisJS
MIT License
116 stars 39 forks source link

fix: Add 'true' and 'false' to boolean value (#86) #87

Closed Dolu89 closed 4 years ago

Dolu89 commented 4 years ago

Proposed changes

It should be added because edge template receive 'true' or 'false' as value when doing this : Controller.ts

const myObjectWithBoolean = await MyObjectWithBoolean.query()....firstOrFail() //{myBoolean: true}
return view.render('myView', {...myObjectWithBoolean.toJSON()})

view.edge <p>{{myBoolean}}</p> => display 'true', not 1, '1' or 'on'

eg.

<div x-data="{ showMessage: {{show_message}} }">
  <input type="checkbox" x-model="showMessage">
  <input type="hidden" name="showMessage" :value="showMessage">
</div>

Types of changes

What types of changes does your code introduce?

Put an x in the boxes that apply

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

Further comments

/

thetutlage commented 4 years ago

Thanks for it. Before I publish it, can you please also create another PR for the docs? https://github.com/adonisjs/adonisjs.com/blob/develop/docs/docs/guides/03-validator/03-data-types.md

Dolu89 commented 4 years ago

Thanks for it. Before I publish it, can you please also create another PR for the docs? https://github.com/adonisjs/adonisjs.com/blob/develop/docs/docs/guides/03-validator/03-data-types.md

I don't understand, there is already 'true' and 'false' in the list

"1", 1, "on", "true" is casted to true. "0", 0, "off", "false" is casted to false.

thetutlage commented 4 years ago

Ohh okay. Ignore it then 🙂