Fonk Doc
1. General
FonkGetting StartedValidation SchemaField ValidationRecord ValidationForm Validation
2. Validators
3. Messages
4. Form Libraries
5. API
6. Posts

Fonk

Fonk is a pure javascript form validation library.

It allows you to:

- Define validations that apply to your form in a declarative way.

- Isolate your form validation business logic from the UI.

- Remove the need of mount the UI in order to unit test your form validations.

- Create reusable validation rules that can be easily unit tested.

Example

// The model
const loginRecord = {
user: '',
password: ''
};
// The validation schema
import { Validators, createFormValidation } from '@lemoncode/fonk';
const validationSchema = {
field: {
user: [Validators.required],
password: [Validators.required]
}
};
const formValidation = createFormValidation(validationSchema);
// Execute form validation
formValidation
.validateField('user', loginRecord.user)
.then(validationResult => {
console.log(validationResult);
});
// The result
{
succeeded: false,
message: 'Please fill in this mandatory field.',
type: 'REQUIRED'
}

validate-field

Try it out in Javascript

Try it out in Typescript

Fonk is framework extension, and can be easily plugged into many libraries / frameworks, in this documentation you will find integrations with:

- Plain Vanilla ES6.

- React.

- React Final Forms.

- Formik.

- Vuejs.