Coder Social home page Coder Social logo

next-practice-health's Introduction

React Form Schema Generation

Description

JSON-based form definition generated from object schema and form definition.

Please see sample layouts below:

Schema: Object property metadata

{
        "name": "registration",
        "desc": "Patient Registration",
        "properties": {
            "fullName" : {
                "title": "Full name",
                "type": "string"
            },
            "birthday" : {
                "title": "Birthday",
                "type": "date"
            },
            "gender" : {
                "title": "Gender",
                "type": "enum",
                "values": {
                    "male" : "Male",
                    "female" : "Female"
                }
            },
            "mobile" : {
                "title": "Mobile",
                "type": "string"
            },
            "home" : {
                "title": "Home",
                "type": "string"
            },
            "guardianConsent" : {
                "title": "Guardian consent",
                "type": "boolean"
            },
            "guardian": {
                "title": "Guardian",
                "type": "string"
            }
        }
    }; 

Form: Form layout logic and validation

    {
        "name": "registrationForm",
        "title": "Registration form",
        "fields": {
            "fullName" : {
                "validators": {
                    "required": true,
                    "containsASpace" : true
                },
                "defaultErrorMsg" : "Name must contain a space"
            },
            "birthday": {
                "validators": {
                    "required": true,
                    "ageFromDate": 18
                },
                "defaultErrorMsg" : "Your must be 18 years or older"
            },
            mobile: {},
            home: {},
            gender: {},
            guardianConsent: {},
            guardian: {
                "when" : "guardianConsent",
                "validators": {
                    "required": true,
                    "containsASpace" : true
                },
                "defaultErrorMsg" : "Guardian name must contain a space"
            }
        }
    } 

Todo

  • Apply correct UI styling
  • Add robust error handling
  • Tidy up validation logic
  • Group fields like contacts in an array
  • Group fields also can hidden or shown as group (instead of each individual fields)
  • Allow fields to be group and, if required, multiple fields per line
  • Add jest snapshot tests
  • Add new widgets, such as select box
  • See if the useForm NPM package (which is excellent) can have a better and consistent validation method. For example, custom validation don't permit an associated message.

Prerequisites

Please ensure that the latest version of NPM and NodeJs are installed

Installing

npm install 

Run sample executions

npm start

Running the tests

npm run test

Author

Paul Caruana

next-practice-health's People

Watchers

James Cloos avatar PassionatePaul avatar

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.