dwyl / abase

:house: A (solid) Base for your Web Application.
9 stars 0 forks source link

Look into the Joi objects #15

Open samhstn opened 7 years ago

samhstn commented 7 years ago

Identify the interface the Joi objects provide in order to render the html form and input into our database

eliasmalik commented 7 years ago

On the DB side, we will need to look at the schema provided by the developer in order to infer what data-types each field needs to be. For example

var schema = {
  username: Joi.string().min(2).max(15),
  email: Joi.string().email(),
}

If this is the schema object the backend has to rely on, in order to find out what datatype username has to be, we would have to access

schema.username._type

The underscore prefix suggests this is intended to be a private member. All the other properties that tell us about restrictions are also private. Do we want to be coupling this module/plugin to the internal implementation of Joi objects?

Does anyone know of a better way to infer data-type? @nelsonic ?

nelsonic commented 7 years ago

@eliascodes our initial discussion of Joi's limitations specifically regarding our need for defining access controls in the model lead me to think we may want to write our own JSON format ...

It might be worth taking a look at: https://github.com/json-schema-org/json-schema-spec

relates to: #19 & #26