You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
Go to file
Björn c5b237dd2b
adding
4 years ago
dist adding 4 years ago
src adding 4 years ago
.gitignore adding 4 years ago
README.md adding 4 years ago
demo.js adding 4 years ago
demo.riot adding 4 years ago
mix-manifest.json adding 4 years ago
package-lock.json adding 4 years ago
package.json adding 4 years ago
webpack.mix.js adding 4 years ago

README.md

Tiny Validator

Created with Riot.js

Validate Form or a Single Form-Field, Error Messages can be show just in time or after Submit entire Form.

For Validation this Component uses Validate.js

Install

npm install tiny-validator --save

How to use

<demo>
    <form onsubmit={ (event) => { state.validator.handle(event) }} novalidate>
        <div class="field">
            <label>
                email
                <input type="email" name="email" onkeyup={ (event) => { state.validator.handle(event, 'email') }} />
            </label>
            <field-error errors={ state.validator.errors('email') } ></field-error>
        </div>
        <div class="field">
            <label>
                password
                <input type="password" name="email" onkeyup={ (event) => { state.validator.handle(event, 'password') }} />
            </label>
            <field-error errors={ state.validator.errors('password') } ></field-error>
        </div>
        <button type="submit">Send</button>
    </form>

    <script>

        import Validator from './validator.js'

        export default {
            onBeforeMount() {
                this.state.validator = new Validator({
                    name: {
                        presence: true
                        email: true
                    },
                    password: {
                        presence: true
                    }
                }, this)
            }
        }
    </script>
</demo>

Demo