4 Forms

4 Forms

  • Getting Started
  • API
  • Github
  • Help

›API Reference

Introduction

  • Getting Started
  • Installation
  • Motivation
  • Examples

Guides

  • Intro
  • Field
  • Schema
  • Nested schema
  • Related Field

API Reference

  • API Reference
  • Field
  • Schema
  • When
  • Rules

    • Generic
    • String
    • Number
    • Boolean
    • Array
    • Object
    • Iterator

Array

Rules for array validation.

NOTE : Array type can accept rules of iterator.

Methods

  • allEquals(value, [options])
  • allExact(value, [options])

Reference

allEquals(value, [options])

checks if the all values of the array field is equals to the value given as argument.

Optionally, you can provide a options object that can hold message and constraints.

NOTE : allequals use the operator == for equality.

Example

import { Field } from "v4f";

const field = Field()
    .array()
    .allEquals(4);

field.validate([4, 4, 4]); // true
field.validate([4, "4", 4]); // true
field.validate([4, 4, 6]); // false

allExact(value, [options])

checks if the all values of the array field is strict equals to the value given as argument.

Optionally, you can provide a options object that can hold message and constraints.

NOTE : allExact use the operator === for equality.

Example

import { Field } from "v4f";

const field = Field()
    .array()
    .allEquals(4);

field.validate([4, 4, 4]); // true
field.validate([4, "4", 4]); // false
field.validate([4, 4, 6]); // false
← BooleanObject →
  • Methods
  • Reference
    • allEquals(value, [options])
    • allExact(value, [options])
4 Forms
Docs
Getting StartedGuidesAPI Reference
Community
Stack OverflowProject ChatTwitter
More
GitHub
Copyright © 2019 Soufiane Nassih