All Projects → julianfalcionelli → MagicForm

julianfalcionelli / MagicForm

Licence: Apache-2.0 license
The easiest way to make complex forms with validations.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to MagicForm

Eureka
Elegant iOS form builder in Swift
Stars: ✭ 11,345 (+36496.77%)
Mutual labels:  forms, validations
forms
A library to build declarative, composable, reactive user interfaces with WebSharper.
Stars: ✭ 12 (-61.29%)
Mutual labels:  forms
insect
🛠 Highly customisable, minimalistic input x select field for React.
Stars: ✭ 33 (+6.45%)
Mutual labels:  forms
streaming-form-data
Streaming parser for multipart/form-data written in Cython
Stars: ✭ 112 (+261.29%)
Mutual labels:  forms
ember-validated-form-buffer
A validated form buffer that wraps Ember Data models for use in forms.
Stars: ✭ 46 (+48.39%)
Mutual labels:  forms
FilterInputJs
Tiny and Powerful Library for limit an entry (text box,input) as number,string or more...
Stars: ✭ 37 (+19.35%)
Mutual labels:  validations
LC-switch
Superlight vanilla javascript plugin improving forms look and functionality
Stars: ✭ 31 (+0%)
Mutual labels:  forms
SuluCommunityBundle
Community features like Login, Registration, Password forget/reset for your sulu application.
Stars: ✭ 20 (-35.48%)
Mutual labels:  forms
talos
Elixir parameter validation library. Simple and extensible
Stars: ✭ 23 (-25.81%)
Mutual labels:  forms
react-forms-processor
A forms processor for React
Stars: ✭ 63 (+103.23%)
Mutual labels:  forms
edulabs
No description or website provided.
Stars: ✭ 15 (-51.61%)
Mutual labels:  forms
RapidFormBundle
Create Symfony forms at record speed using PHP 8 attributes!
Stars: ✭ 33 (+6.45%)
Mutual labels:  forms
ember-validity-modifier
Ember Octane addon to add custom validity (form validation) to form fields
Stars: ✭ 28 (-9.68%)
Mutual labels:  forms
form-saver
A simple script that lets users save and reuse form data.
Stars: ✭ 67 (+116.13%)
Mutual labels:  forms
final-form-arrays
Array Mutators for 🏁 Final Form
Stars: ✭ 64 (+106.45%)
Mutual labels:  forms
ng-xform
esss.github.io/ng-xform/home
Stars: ✭ 18 (-41.94%)
Mutual labels:  forms
platform
A collection of minimalistic, easy-to-use and fully customizable Angular components, directives and services
Stars: ✭ 17 (-45.16%)
Mutual labels:  forms
Formidable
The PHP pragmatic forms library
Stars: ✭ 116 (+274.19%)
Mutual labels:  forms
RDForm
Create and edit RDF data in a HTML form
Stars: ✭ 16 (-48.39%)
Mutual labels:  forms
swagger-editor-validate
This GitHub Actions validates OpenAPI (OAS) definition file using Swagger Editor.
Stars: ✭ 30 (-3.23%)
Mutual labels:  validations

MagicForm

Android Arsenal

Magic Form allows fast, easy and customisable creation of forms with validations.

Setup

dependencies {
    implementation 'io.github.julianfalcionelli:MagicForm:1.5.1'
}

Use

All you need to do is create a MagicForm object and then gradually add the form fields with their validations.

Example:

MagicForm mMagicForm = new MagicForm()
				.addField(
					new FormField(mEmailEditText)
						.addValidation(
							new ValidationRegex(Patterns.EMAIL_ADDRESS)
								.setMessage("invalid email"))
				)
				.addField(
					new FormField(mPasswordEditText)
						.addValidation(
							new ValidationNotEmpty()
								.setMessage("Required Field"))
				)
				.setListener(this);

Adds a listener to perform certain events if the form is valid or invalid.

Otherwise you can call the isValid() method.

Validation mode

A very important feature is that MagicForm can validate in different ways, by setting one mode to the entire form or to each field.

Available modes:

  • ON_VALIDATE: Default mode of the form. The form is validated with the call of validate() method.
  • ON_CONTENT_CHANGE: The form is validated each time you change the content / state of the fields.
  • ON_FOCUS_CHANGE: Fields are validated each time lose their focus.

Validations

It allows you to create custom validations very easily through the Validations class, or can use the already available:

  • ValidationLength
  • ValidationMaxLength
  • ValidationMinLength
  • ValidationNotEmpty
  • ValidationRegex
  • ValidationChecked (Useful for Checkbox, Switch)
  • more

If you want to reuse validations on various parts of your application we suggest you make a class extending of Validation. Also you can create it inline, when you are creating the form.

MagicForm power

MagicForm mMagicForm = new MagicForm(ValidationMode.ON_CONTENT_CHANGE)
				.addField(
					new FormField(mEmailEditText)
						.addValidation(
							new ValidationRegex(Patterns.EMAIL_ADDRESS)
								.setMessage("invalid email"))
				)
				.addField(
					new FormField(mPasswordEditText)
						.addValidation(
							new ValidationNotEmpty()
								.setMessage("Required Field"))
						.addValidation(
							new ValidationLength(2, 4))
				)
				.addField(
					new FormField(this, R.id.fieldEditText)
						.addValidation(
							new Validation<EditText>() {
								@Override
								public boolean isValid(EditText view) {
									return view.getText().equals("something");
								}
						}.setMessage("Invalid field!!!"))
				)
				.addField(
					new FormField(mCheckBox)
						.addValidation(
							new ValidationChecked(true))
				)
				.setListener(
					new ValidatorCallbacks() {
						@Override
						public void onSuccess() {
							Log.i("MagicForm", "Valid!");
						}

						@Override
						public void onFailed(List<FormError> errors) {
							Log.i("MagicForm", "Invalid!");
						}
				});

License

Copyright 2016 Julián Falcionelli

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].