Code Monkey home page Code Monkey logo

reschema's People

Contributors

andremw avatar enieber avatar fakenickels avatar rescriptbr-admin avatar vmarcosp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

reschema's Issues

Unexpected validation pass about nested fields

@mununk reported on ReForm (rescriptbr/reform#244):

I encounter a weird unexpected validation pass about the nested field array. Here is my example:

module ProfileFormFields = %lenses(
  type t = {
    nickname: string,
    age: int,
  }
)

module FormFields = %lenses(
  type state = {
    name: string,
    email: string,
    profiles: array<ProfileFormFields.t>,
  }
)

module Form = ReForm.Make(FormFields)
...
        schema([
          custom(({profiles}) => {
            let errors: array<ReSchema.childFieldError> = // <-- 1
              profiles
              ->Array.mapWithIndex((index, profile) =>
                if profile.nickname == "" || profile.age <= 0 {
                  let error: ReSchema.childFieldError = {
                    error: "Invalid profile",
                    index,
                    name: "???",
                  }
                  Some(error)
                } else {
                  None
                }
              )
              ->Array.keepMap(x => x)

            switch errors {
            | [] => Valid
            | _ => NestedErrors(errors) // <- 2. return NestedErrors!
            }
          }, Profiles)
        ])
...

Field(Profiles)->form.getNestedFieldError(index)->Js.log // errors are all None??

The length of errors in comment:1 is not 0, so it means that this predicate function returns NestedErrors(errors). But none of the indexes in the nested field has an error. So, the submission proceeded even though the nested fields are not satisfied in the custom schema.

I guess that validate function (https://github.com/rescriptbr/reschema/blob/master/src/ReSchema.res#L287:L292) in ReSchema should check the NestedErrors there. Or anything I missed for the nested fields validation?

remove js export to export with .mjs

Error: Cannot find module 'project_folder/node_modules/@rescriptbr/reschema/src/ReSchemaRegExp' imported from project_folder/node_modules/@rescriptbr/reschema/src/ReSchema.mjs

when I starting the investigation the bug I find this file with module.exports.email = email in js file, when use the "suffix": ".bs.js", no has error, but when you use "suffix": ".mjs", using ES6 module has error because no has option import email regex with module.exports

ReSchema v3

TODO

  • New schema API (#5).
  • New package on npm (from reschema to @rescriptbr/reschema).
  • Add a deprecation note on the old package.
  • Update doc examples
  • API Reference for the new schema API
  • Release version

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.