Giter Club home page Giter Club logo

fm-json-validation's Introduction

JSON.Validate Custom Functions

For FileMaker Pro 16 and above

Introduction

Validating JSON with Script Steps can be tedious. For example, If I want to validate three properties of my JSON in a script I may have to do this.

Imperitive Vs Declaritive

This tedious becuase we have to tell FileMaker how to validate the object imperitively. If we could simply "Declare" our rules it would be easier.

Here is that same logic usign Custom Functions to Declaratively validate our JSON

If all rules failed passed we'd get

{
  "errorCode" : 0
}

If any of these rules fail we'll get an Error as the result of this function. If they all failed it would look like this. Notice the individual errors are added to an "errors" property.

{
	"errorCode" : -2,
	"errors " : 
	[
		{
			"descriptor" : "Required value is missing",
			"errorCode" : -2,
			"path" : "firstName",
			"type" : "JSON.Validate"
		},
		{
			"descriptor" : "Required value is missing",
			"errorCode" : -2,
			"path" : "lastName",
			"type" : "JSON.Validate"
		},
		{
			"descriptor" : "Should be one of male,female",
			"errorCode" : -2,
			"path" : "gender",
			"type" : "JSON.Validate"
		}
	],
	"type" : "JSON.Validate"
}

This "error" JSON follows the format we have described in the Error Custom Function Repo. There is a function in that set, called Error.IsError(), that can detect if the above JSON is an "error"

Documentation and Usage

Check out the Tests in the JSON.Validate.fmp12 file. They should show you how to use it.

Also each function is documented here and in the CF itself.

fm-json-validation's People

Contributors

toddgeist avatar lancebrandenberg avatar luidog avatar

Watchers

Caleb Angelino avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.