{"id":16022876,"url":"https://github.com/smacker/valya-forms","last_synced_at":"2025-09-07T08:46:12.366Z","repository":{"id":57390555,"uuid":"50328216","full_name":"smacker/valya-forms","owner":"smacker","description":"Wrapper for valya to make forms easier","archived":false,"fork":false,"pushed_at":"2016-02-16T05:45:17.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-17T04:37:45.858Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smacker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-25T05:25:48.000Z","updated_at":"2016-01-25T05:26:25.000Z","dependencies_parsed_at":"2022-09-26T16:51:17.560Z","dependency_job_id":null,"html_url":"https://github.com/smacker/valya-forms","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/smacker/valya-forms","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fvalya-forms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fvalya-forms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fvalya-forms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fvalya-forms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smacker","download_url":"https://codeload.github.com/smacker/valya-forms/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smacker%2Fvalya-forms/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274015018,"owners_count":25207688,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T18:42:35.616Z","updated_at":"2025-09-07T08:46:12.322Z","avatar_url":"https://github.com/smacker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Valya Forms\n\nValya Forms are just a tiny Higher-Order Components for [Valya](https://github.com/deepsweet/valya).\n\nIt provides props `isValid` and `isValidating` for wrapped component according to states of validators.\nAlso it allows set `initialValidation` in form for all validators of this form.\n\n### Example\n\nFirst we need to create valya validator and return it in wrapper:\n\n```js\nimport { Component } from 'react';\nimport { ValidatorWrapper } from 'valya-forms';\nimport Valya from 'valya';\n\nclass Validator extends Component {\n    renderError() {\n        const { shouldValidate, isValid } = this.props;\n\n        if (!shouldValidate || isValid) {\n            return null;\n        }\n\n        return \u003cdiv className=\"error\"\u003e{this.props.validationMessage}\u003c/div\u003e;\n    }\n\n    render() {\n        return (\n            \u003cdiv className=\"validator\"\u003e\n                \u003cdiv className=\"target\"\u003e{this.props.children}\u003c/div\u003e\n                {this.renderError()}\n            \u003c/div\u003e\n        );\n    }\n}\n\n// This is only change\n// We export not Valya(Validator) but ValidatorWrapper(Valya(Validator))\nexport default ValidatorWrapper(Valya(Validator));\n```\n\nThen we create form and wrap it too:\n\n```js\nimport { Component } from 'react';\nimport { FormWrapper } from 'valya-forms';\nimport Validator from './validator';\n\n// simple react form component\nclass MyForm extends Component {\n    constructor(props, context) {\n        super(props, context);\n\n        this.state = {\n            email: props.email\n        };\n\n        this._onEmailChange = this._onEmailChange.bind(this);\n    }\n\n    _onEmailChange = (e) =\u003e {\n        this.setState({\n            email: e.target.value\n        });\n    };\n\n    render() {\n        // injected props by wrapper\n        let { isValid, isValidating } = this.props;\n\n        return (\n            {/* prop initialValidation will be passed to all validators */}\n            \u003cform initialValidation={true}\u003e\n                {/* name \u0026 value props are required\n                    they will be passed to valya and underlying component */}\n                \u003cValidator name=\"email\" value={this.state.email} validators={validators}\u003e\n                    \u003cinput onBlur={this._onEmailChange} /\u003e\n                \u003c/Validator\u003e\n                \u003cdiv\u003e{isValidating ? 'processing validation' : 'validation finished'}\u003c/div\u003e\n                \u003cdiv\u003eForm is {isValid ? 'valid' : 'invalid'}\u003c/div\u003e\n            \u003c/form\u003e\n        );\n    }\n}\n\n// export form in wrapper\nexport default FormWrapper(MyForm);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmacker%2Fvalya-forms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmacker%2Fvalya-forms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmacker%2Fvalya-forms/lists"}