import { NucleoPrimitiveType } from './../_types/NucleoPrimitiveType' ; type UserFormatValidation < T > = ( arg : T ) => boolean ; export class NucleoCustomPrimitive < T > { Type : string ; userFormatValidation : UserFormatValidation < T > ; nativeType : string ; serialize ( value ) { if ( typeof value !== 'boolean' && ( typeof value !== this . nativeType || this . formatValidation ( value ) ) ) { return false ; } return true ; } formatValidation ( value ) { if ( this . userFormatValidation ) { return ! this . userFormatValidation ( value ) ; } return false ; } } export class NucleoStringAssertion < T > extends NucleoCustomPrimitive < T > { constructor ( userFormatValidation ) { super ( ) ; this . Type = 'NucleoString' ; this . nativeType = 'string' ; this . userFormatValidation = userFormatValidation ; } } export class NucleoNumberAssertion < T > extends NucleoCustomPrimitive < T > { constructor ( userFormatValidation ) { super ( ) ; this . Type = 'NucleoNumber' ; this . nativeType = 'number' ; this . userFormatValidation = userFormatValidation ; } } export const NucleoString = { Type : 'NucleoString' , serialize : ( value ) : boolean => { if ( typeof value !== 'string' ) { return false ; } return true ; } } ; export const NucleoNumber = { Type : 'NucleoNumber' , serialize : ( value ) : boolean => { if ( typeof value !== 'number' ) { return false ; } return true ; } } ; export const NucleoBoolean = { Type : 'NucleoBoolean' , serialize : ( value ) : boolean => { if ( typeof value !== 'boolean' ) { return false ; } return true ; } } ;