Coder Social home page Coder Social logo

Comments (9)

rkoszalka avatar rkoszalka commented on May 31, 2024 1

Hello, I don't know if you have found a fix for this problem.

The model.value array of form send and empty string "" instead of null for fields that are not filled. I've managed to find an workaround for this, for my required fields i'm setting an minLength of one.

from ngx-schema-form.

SBats avatar SBats commented on May 31, 2024

Hi @raphaelkoszalka. Thank you for this workaround!
We're investigating on this bug but it's nice to have a temporary fix for users

from ngx-schema-form.

rkoszalka avatar rkoszalka commented on May 31, 2024

@SBats, i've integrated TV4 with angular-2schema-form module, in that way i've managed to properly validate required properties.

If you're interested in the weekend i can open a pull request with that change (tv4 instead of z-scheme for validation).

I just can't do right now because i'll be working untill saturday morning on a project.

from ngx-schema-form.

SBats avatar SBats commented on May 31, 2024

I must say I don't know yet well the whole module, and at the moment can't say I have an opinion on z-schema vs TV4.
Maybe @fbessou or @ebrehault knows better about this specific point as they chose z-schema?
From my point of view, if the functional scope is not lowered and it fixes bugs, I'm all in! :)

Of course, if you find time to make a PR, we'll be really glad about it! But no rush needed, so take the time you need and don't hesitate to ask questions.

from ngx-schema-form.

fbessou avatar fbessou commented on May 31, 2024

Hello there. @raphaelkoszalka, if you have extended the SchemaValidatorFactory class it shouldn't be hard to integrate tv4 in angular2-schema-form.

Currently, the ZSchemaValidatorFactory is hard coded in the FormComponent but it could be provided at module level to allow overriding.

At first, z-schema was chosen because of the set of features it provides and its performances: https://github.com/ebdrup/json-schema-benchmark

from ngx-schema-form.

kianmeng-aft avatar kianmeng-aft commented on May 31, 2024

hey there,

i am also facing the same issue , the minLength workaround works!!

but is it part of the plan to fix this in the future release instead of adding the minLength ??

from ngx-schema-form.

lzoubek avatar lzoubek commented on May 31, 2024

Hi, I am also facing this issue, but I don't like minLength workaround. z-schema has already support for empty string validation. So I think the best solution is a possibility to inject custom implementation of SchemaValidatorFactory. I'll try to open a PR for it

from ngx-schema-form.

lzoubek avatar lzoubek commented on May 31, 2024

PR #108

from ngx-schema-form.

daniele-pecora avatar daniele-pecora commented on May 31, 2024

A custom SchemalValidatorFactory can new be defined via module providers.
Example:

...
import {SchemaFormModule, SchemaValidatorFactory, WidgetRegistry} from 'ngx-schema-form';
import {
  Custom_FixOptionalEmptyFieldsZSchemaValidatorFactory,
} from './cutsom-validator-factory';

@NgModule({
  providers: [
     ...
    {provide: SchemaValidatorFactory, useClass: Custom_FixOptionalEmptyFieldsZSchemaValidatorFactory}
  ],
  declarations: [ ... ],
  imports: [ ... ],
  bootstrap: [ ... ]
})

export class AppModule {
}

from ngx-schema-form.

Related Issues (20)

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.